PIA general routines

This page was created by the IDL library routine mk_html_help. For more information on this routine, refer to the IDL Online Help Navigator or type:

     ? mk_html_help

at the IDL command line prompt.

Last modified: Fri Mar 24 12:48:08 2000.


List of Routines


Routine Descriptions

AAP_DISC

[Next Routine] [List of Routines]
 NAME:
       AAP_DISC

 PURPOSE:
       Return a flag array with flag=2 for all the chopper plateaux
       discarded using the bitflag system

 CATEGORY:
	PIA - processing

 CALLING SEQUENCE:
       AAP_DISC, Tmpdata, Flagarr

 INPUTS:
       Tmpdata: PHTAAP type temporary structure

 OUTPUTS:
       Flagarr: Flag array of dimensions (# pixels, # chopper plateaux)
		 # pixels does not include resistor and open pixel  

 PROCEDURES USED:
       None

 MODIFICATION HISTORY:
	Written by: Carlos Gabriel - ESA-SAI
	Changed according to bitflag system (CG)
	V7.4

(See /aap_disc.pro)


AAP_INIT

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       aap_init
 PURPOSE:
       Initializes the structure PHTAAP defining the contents as
	a template structure PHTAAP_TYPE. It can be used for clearing
	the whole AAP structure, in case this should show as necessary. 
 CATEGORY:
	PIA - initialization

 CALLING SEQUENCE:
       AAP_INIT

 INPUT PARAMETERS:
	None       

 OUTPUT PARAMETERS: 
	None

 KEYWORDS:
	Index:	If set, only those will be deleted from buffer

 PROCEDURES USED:
       Common Block(s) or @ procedure(s):
               phtaap
               phtaap_init

 MODIFICATION HISTORY:
       Written by: C. Gabriel (ESA/VILSPA-SAI)		January 1996
	Keyword index for clearing set of records added (CG+JA)	May 1997
	V6.3

(See /aap_init.pro)


AAR_INIT

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       AAR_INIT

 PURPOSE:
       Initializes the structure PHTAAR defining the contents as
	a template structure PHTAAR_TYPE. It can be used for clearing
	the whole AAR structure, in case this should show as necessary. 

 CATEGORY:
	PIA - initialisation

 CALLING SEQUENCE:
       AAR_INIT

 INPUTS:
	None       

 OUTPUTS: 
	None

 KEYWORDS:
	Index:	If set, only those will be deleted from buffer

 COMMON BLOCKS:
	phtaar
	
 PROCEDURES USED:

 MODIFICATION HISTORY:
       Written by:	Carlos Gabriel
	Oct 95 Version 3.5
	Keyword index for clearing set of records added (CG+JA)	May 1997
	V6.3

(See /aar_init.pro)


ACC_FLG

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	ACC_FLG

 PURPOSE:
	To return an array of flagged read-outs
       taking into account the diverse acceptance 
	criteria for read-outs, reflected in the status word 

 CATEGORY:
	PIA - processing

 CALLING SEQUENCE:
	ACC_FLG, DR, Status

 INPUTS:
	DR	: Array containing the destructive readout word 
	Dim	: Actual measurement length 
	NNDR	: Number of non-destructive read-outs
	Admn	: Internal measurement name  
	OTF	: On target flag

 OUTPUTS:
	Status	: A flag array: 0=accepted, 1=not accepted

 COMMON BLOCKS:
               phtacc
               phtselndr

 PROCEDURE:
	Using the status word, create a flag array
	conform to the acceptance criteria

 PROCEDURES USED:
	PIA LIB: READ_SELNDR

 MODIFICATION HISTORY:
	Written by:	Carlos Gabriel
	Oct 95 Version 3.5
	allowing for gen criteria and 1st NDR deselected (CG)	May 1996

(See /acc_flg.pro)


ACC_VOLT

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	ACC_VOLT

 PURPOSE:
	To return a bad flag array 
	taking into account voltage limits (a minimum 
	and a maximum accepted, e.g. saturation voltage) 
	according to the CB PHTACC  

 CATEGORY:
	PIA - processing

 CALLING SEQUENCE:
	ACC_VOLT, ICONP, VFlag, DR

 INPUTS:
	IConp	: Read-out voltages array
	STFlag	: Status Flag before call
	DR	: Array indicating Destructive Readouts

 OUTPUTS:
	STFlag	: Flag array (Input Vflag + 1:out of voltage limits)
	VFlag   : Flag array (1= out of voltage limits)	

 COMMON BLOCKS:
               phtacc

 PROCEDURE:
	Using the CB PHTACC, flag the values which are
	not conform to the minimum and maximum voltages
	In case that a value is above the allowed maximum voltage, all
	values up to the end of the ramp are flagged as bad 

 MODIFICATION HISTORY:
	Written by:	Carlos Gabriel
	Modified by CG - (last: Nov. 96)
	V5.x
	An additional output (VFLAG) containing pure voltage flag, to
	be consistent with FLAG code (PIA >7.3) 	      JAcosta (May 1999)
	V7.4

(See /acc_volt.pro)


ACKNOWLEDGE

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	ACKNOWLEDGE

 PURPOSE:
	This procedure opens a widget and waits for the user to close it.
	It is a standard solution to the   boxes
	that are so useful in UIs.


 CATEGORY:
	PIA - graphics

 CALLING SEQUENCE:
	ACKNOWLEDGE

 INPUTS:
	None

 KEYWORD PARAMETERS:
	TEXT:       The text to display
	TLB:        Top level base to orient to
	ACK_STRING: String to display on the acknowledge button
	POSITION:   String to give placement guide

 OUTPUTS:
	None

 PROCEDURES USED:
	INTERNAL: ACKNOWLEDGE_EVENT

 EXAMPLE:
	ACKNOWLEDGE, TEXT='Warning: Try again', TLB=widg1

 MODIFICATION HISTORY:
	Written By:	Huw Morris (adapted from Mark Buckley)
	Oct 95 Version 3.5
	/Modal use according to IDL >= 5.0 (CG)
	V7.3

(See /acknowledge.pro)


ADDCOMM2HDR

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	ADDCOMM2HDR
 PURPOSE:
	Procedure to add comment line(s) to FITS header

 CALLING SEQUENCE
	addcomm2hdr, comment, header

 INPUTS:
	comment - string or string array containing comment line(s)
		to add to the header
	header - string array containing the FITS header

 OUTPUTS:
	header - unpdated header

 EXAMPLES:
	addcomm2hdr, 'I DID THIS', header

	comm = strarr(3)
	comm(0) = 'comment line number 1'
	comm(1) = 'the next comment line'
	comm(2) = 'the last comment line'
	addcomm2hdr, comm, header

 Modified from the astronomical library for the ISOPHT FITS header,
	WMT, 	Feb 1996

(See /addcomm2hdr.pro)


ADDPAR2HDR

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	ADDPAR2HDR
 PURPOSE:
	Add or modify a parameter in a FITS header array.

 CALLING SEQUENCE:
	addpar2hdr, Header, Name, Value, [ Comment,  Location, 
				BEFORE =, AFTER = , FORMAT= ]

 INPUTS:
	Header = String array containing FITS header.    The
		length of each element must be 80 characters.    If not 
		defined, then ADDPAR2HDR will create an empty FITS header array.

	Name = Name of parameter. If Name is already in the header the value 
		and possibly comment fields are modified.  Otherwise a new 
		record is added to the header.  If name = 'HISTORY' then the 
		value will be added to the record without replacement.  In 
		this case the comment parameter is ignored.

	Value = Value for parameter.  The value expression must be of the 
		correct type, e.g. integer, floating or string.  String values
		 of 'T' or 'F' are considered logical values.

 OPTIONAL INPUT PARAMETERS:
	Comment = String field.  The '/' is added by this routine.  Added 
		starting in position 31.    If not supplied, or set equal to 
		'', then the previous comment field is retained (when found) 

	Location = Keyword string name.  The parameter will be placed before the
		location of this keyword.    This parameter is identical to
		the BEFORE keyword and is kept only for consistency with
		earlier versions of SXADDPAR.

 OPTIONAL INPUT KEYWORD PARAMETERS:
	BEFORE	= Keyword string name.  The parameter will be placed before the
		location of this keyword.  For example, if BEFORE='HISTORY'
		then the parameter will be placed before the first history
		location.  This applies only when adding a new keyword;
		keywords already in the header are kept in the same position.

	AFTER	= Same as BEFORE, but the parameter will be placed after the
		location of this keyword.  This keyword takes precedence over
		BEFORE.

	FORMAT	= Specifies FORTRAN-like format for parameter, e.g. "F7.3".  A
		scalar string should be used.  For complex numbers the format
		should be defined so that it can be applied separately to the
		real and imaginary parts.

 OUTPUTS:
	Header = updated FITS header array.

 RESTRICTIONS:
	Warning -- Parameters and names are not checked
		against valid FITS parameter names, values and types.

 MODIFICATION HISTORY:
	DMS, RSI, July, 1983.
	D. Lindler Oct. 86  Added longer string value capability
	Converted to NEWIDL  D. Lindler April 90
	Added Format keyword, J. Isensee, July, 1990
	Added keywords BEFORE and AFTER. K. Venkatakrishna, May '92
	Pad string values to at least 8 characters   W. Landsman  April 94
	Mod by W M Tai for the ISOPHT fits file		    Feb 1996

(See /addpar2hdr.pro)


ADD_COORDINATES

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       ADD_COORDINATES

 PURPOSE:
	Assign the coordinates data into the SPD, using routine get_coordinates
 
 CATEGORY:
	PIA - I/O

 CALLING SEQUENCE:
       add_coordinates, tmpdata

 INPUT:
       tmpdata	: phtspd type real structure


 PROCEDURES USED:
       Common Block(s) or @ procedure(s):
       PIA Procedure(s):
               get_coordinates

 MODIFICATION HISTORY:
       Written by: Carlos GABRIEL (ESA/VILSPA-SAI)	January 1996
	Bug for non-existing file fixed (CG)		February 1996
	Bug for large RPID numbers(BYTE*BYTE)fixed (CG)	May 1996
	Using new read_irph call (corrected coord) (CG) September 1997
	V6.5
	Keyword INFO added (JAc)			February 1998
	V7.0
	pcont_getfiles called with NOSORT (CG)		February 1998
	V7.1
	Modified to call directly get_coordinates (JAcosta)  July 1998

(See /add_coordinates.pro)


ADM

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	ADM

 PURPOSE:
	This is not an IDL routine as such, but contains the definition of the
	common block PHTERD for inclusion into other routines.  By defining
	the common block in one place, the problem of conflicting definitions
	is avoided.

	This file is included into routines that need this common block with
	the single line (left justified)

				  @adm

 CATEGORY:
	PIA - common block

 MODIFICATION HISTORY:
	Oct 95 Version 3.5

(See /adm.pro)


ADM_INIT

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       ADM_INIT

 PURPOSE:
       Initializes the structure ADM defining the contents as
	a template structure ADM_TYPE for accomodating IA administration
	data. It can be used also for clearing
	the whole ADM structure, in case this should show as necessary. 


 CATEGORY:
	PIA - Initialisation

 CALLING SEQUENCE:
       ADM_INIT

 INPUTS:
	None       

 OUTPUTS: 
	None

 COMMON BLOCKS:
	adm

 SIDE EFFECTS:
 	Initialises the values held within the adm common block

 PROCEDURES USED:
       None

 MODIFICATION HISTORY:
       Written by:	 C. Gabriel and Wai-Ming Tai
	Oct 95 Version 3.5

	Modified:
	PHTSMD, PHTISMD taken out (SB)			August 1996

(See /adm_init.pro)


AMOEBA

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	AMOEBA

 PURPOSE:
	Multidimensional minimization of a function FUNC(X), where
	X is an N-dimensional vector, using the downhill simplex
	method of Nelder and Mead, 1965, Computer Journal, Vol 7, pp 308-313.

	This routine is based on the AMOEBA routine, Numerical
	Recipes in C: The Art of Scientific Computing (Second Edition), Page
	411, and is used by permission.

 CATEGORY:
	Function minimization/maximization. Simplex method.

 CALLING SEQUENCE:
	Result = AMOEBA(Ftol, ....)
 INPUTS:
    FTOL:  the fractional tolerance to be achieved in the function
	value.  e.g. the fractional decrease in the function value in the
	terminating step.  This should never be less than the
	machine's single or double precision.
 KEYWORD PARAMETERS:
    FUNCTION_NAME: a string containing the name of the function to
	be minimized.  If omitted, the function FUNC is minimized.
	This function must accept an Ndim vector as its only parameter and
	return a scalar single or double precision floating point value as its
	result. 
    FUNCTION_VALUE: (output) on exit, an Ndim+1 element vector
	containing the function values at the simplex points.  The first
	element contains the function minimum. 
    NCALLS: (output) the of times the function was evaluated. 
    NMAX: the maximum number of function evaluations allowed
	before terminating.  Default = 5000.
    P0: Initial starting point, an Ndim element vector.  The starting
	point must be specified using either the keyword SIMPLEX, or P0 and
	SCALE.  P0 may be either single or double precision floating.
	For example, in a 3-dimensional problem, if the initial guess
	is the point [0,0,0], and it is known that the function's
	minimum value occurs in the interval: -10 <
	X(0) < 10, -100 < X(1) < 100, -200 < X(2) < 200, specify: P0=[0,0,0],
	SCALE=[10, 100, 200]. 
    SCALE: a scalar or Ndim element vector contaiing the problem's
	characteristic length scale for each dimension.
	SCALE is used with P0 to form an initial (Ndim+1) point simplex.
	If all dimensions have the same	scale, specify a scalar.
    SIMPLEX: (output and/or optional input) On input, if P0 and SCALE
	are not set, SIMPLEX contains the Ndim+1 vertices, each of
	Ndim elements, of starting simplex, in either single or double
	precision floating point, in an (Ndim, Ndim+1) array. On output,
	SIMPLEX contains the simplex, of dimensions (Ndim, Ndim+1), enclosing
	the function minimum.  The first point, Simplex(*,0), corresponds to
	the function's minimum.

 OUTPUTS:
   Result: If the minimum is found, an Ndim vector, corresponding to
	the Function's minimum value is returned.  If a function minimum
	within the given tolerance, is NOT found in the given number of
	evaluations, a scalar value of -1 is returned.

 COMMON BLOCKS:
	None.

 SIDE EFFECTS:
	None.

 PROCEDURE:
	This procedure implements the Simplex method, described in
	Numerical Recipes, Section 10.4.  See also the POWELL procedure.

	Advantages:  requires only function evaluations, not
	derivatives, may be more reliable than the POWELL method.
	Disadvantages: not as efficient as Powell's method, and usually
	requires more function evaluations.

	Results are performed in the mode (single or double precision)
	returned by the user-supplied function.  The mode of the inputs P0,
	SCALE, or SIMPLEX, should match that returned by the function. The
	mode of the input vector supplied to the user-written function, is
	determined by P0, SCALE, or SIMPLEX.

 EXAMPLE:
	Use Amoeba to find the slope and intercept of a straight line fitting
	a given set of points minimizing the maximum error:

	The function to be minimized returns the maximum error,
	given p(0) = intercept, and p(1) = slope:
 FUNCTION FUNC, p
 COMMON FUNC_XY, x, y
 RETURN, MAX(ABS(y - (p(0) + p(1) * x)))
 END

	Put the data points into a common block so they are accessible to the
	function: 
 COMMON FUNC_XY, x, y
	Define the data points:
   x = findgen(17)*5
   y = [ 12.0,  24.3,  39.6,  51.0,  66.5,  78.4,  92.7, 107.8, 120.0, $
        135.5, 147.5, 161.0, 175.4, 187.4, 202.5, 215.4, 229.9]

	Call the function.  Fractional tolerance = 1 part in 10^5, 
	Initial guess = [0,0], and the minimum should be found within
	a distance of 100 of that point: 
   r = AMOEBA(1.0e-5, SCALE=1.0e2, P0 = [0, 0], FUNCTION_VALUE=fval)

	Check for convergence:
   if n_elements(r) eq 1 then message,'AMOEBA failed to converge'
	Print results.
   print, 'Intercept, Slope:', r, 'Function value (max error): ', fval(0)
Intercept, Slope:      11.4100      2.72800
Function value:       1.33000

 MODIFICATION HISTORY:
	DMS, May, 1996.	Written.

(See /amoeba.pro)


ANAL_FPGC

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
     ANAL_FPGC

 PURPOSE:
       Analyse a Focal Plane Geometry Calibration File and and compare
	it to theoretical raster.

 CATEGORY:
	PIA - processing

 CALLING SEQUENCE:
	ANAL_FPGC, Infile, ERROR=error

 INPUTS:
 	Infile: name of FPGC file

 KEYWORD PARAMETERS:
	ERROR: Returns error status:
		0 = no error
		1 = error: output is not valid

 OUTPUTS:
	Text: print-out contents of FPGC file

 PROCEDURES USED:
	PIA LIB: read_fpgc
       PIA LIB: pia_xplot

 MODIFICATION HISTORY:
       Written by:	I. Heinrichsen
	Modified by:	C. Gabriel

	Oct 95 Version 3.5

	Modified by:	I. Heinrichsen	Rotation angle, coordinate  Oct. 95
					display corrected
			IH		Change axes label
					invert theoretical coordinates Nov. 95

(See /anal_fpgc.pro)


ANAL_SIG

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
     ANAL_SIG

 PURPOSE:
       Analyse several SRD/SCP measurements

 CATEGORY:
	PIA - processing

 CALLING SEQUENCE:
	ANAL_SIG, ind, orbstr

 INPUTS:
	Ind: index array containing indexes for extraction from SRD structure


 KEYWORD PARAMETERS:

	TYPE 	type of PIA structure to be analysed (SRD of SCP), default=SRD

	ERROR		Returns an error status:
						0 = no error
						1 = error: output is not valid

 OUTPUTS:
	ADMN    administration name
	TIME	array with absolute times for SIGNAL and NOISE
	SIGNAL	array of signals (SLOP, AVER) per detector for all 
		selected measurements from ind
	NOISE	array of  uncertainties per detector (SLUN, AVUN) for all 
		selected measuremenst from ind
	FLAGS  	array of flags per detector (FLAG) for all 
		selected measuremenst from ind
	ST_TIME	Absolute start time (STRING)

 COMMON BLOCKS:
	phtsrd
	phtscp

 PROCEDURES CALLED:

 RESTRICTIONS
	Due to the nature of the timing information for PHT the absolute 
	start time of the contained measuremnets are not as accurate as 
	as the relative times within a measurement 

 MODIFICATION HISTORY:
       Written by:	Ingolf Heinrichsen		December 1995
	Bug fixed (CG)	(phtsrd instead phtscp)		January 1996
	time and other arrays now of same dims (CG)	February 1996
	Bug for 1 pixel & 1 signal fixed (CG)		February 1996
	Change call of date_conv to unit2juldate +
	    adding admn as output                (JAc)  January 1998

(See /anal_sig.pro)


APERTURE_INFO

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	APERTURE_INFO

 PURPOSE:
	This is not an IDL routine as such, but contains the definition of the
	common block APERTURE_INFO for inclusion into other routines.  By 
	defining the common block in one place, the problem of conflicting 
	definitions is avoided.

	This file is included into routines that need this common block with
	the single line (left justified)

				  @aperture_info


	This file stores data about the phot apertures

	APERTURE_INFO contains the following variables:

	  N_Filt : Number of filters (PHT-P, PHT-C)

	  N_Aper : Number of apertures for PHT-P

	  P_WaveL : Centre wavelengths for PHT-P (array)

	  C_WaveL : Centre wavelengths for PHT-C (array)

	  P_Ratio : Relative detector response at the central wavelength

	  C_Ratio : Relative detector response at the central wavelength

	  Point_Spread : Point Spread Function for PHT-P, PHT-C

 CATEGORY:
	PIA - common block

 MODIFICATION HISTORY:
	Written by:	Huw Morris
	Oct 95 Version 3.5

(See /aperture_info.pro)


APERTURE_INFO_INIT

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	APERTURE_INFO_INIT

 PURPOSE:
	This procedure initialises the Aperture_Info common block

 CATEGORY:
	PIA - initialisation

 CALLING SEQUENCE:
	APERTURE_INFO_INIT

 INPUTS:
	None

 OUTPUTS:
	None

 COMMON BLOCKS:
	aperture_info
	phtppsf

 SIDE EFFECTS:
	The variables in the aperture info common block are initialised here

 MODIFICATION HISTORY:
	Written by:	Huw Morris
	Oct 95 Version 3.5
	

(See /aperture_info_init.pro)


APERTURE_SIZE_INIT

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	APERTURE_SIZE_INIT

 PURPOSE:
	This procedure initialises the phtapertures common block

 CALLING SEQUENCE:
	APERTURE_SIZE_INIT

 INPUTS:
	None

 OUTPUTS:
	None

 COMMON BLOCKS:
	phtapertures

 SIDE EFFECTS:
	The variables in the phtapertures common block are initialised

 PROCEDURES USED:
	None

 MODIFICATION HISTORY:
	Written by:	Huw Morris
	Oct 95 Version 3.5
	Modified by: CG - Measured diameters and omegas in.	December 1996
	CG - Now reading data from POMEGA.FITS file		January 1997
	V6.0

(See /aperture_size_init.pro)


APPEND_RP

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	APPEND_RP

 PURPOSE:
	Merge pseudo measurements per RPID into an SCP unique measurement

 CATEGORY:
	PIA - processing

 CALLING SEQUENCE:
	APPEND_RP, indices, scpps

 INPUT PARAMETERS:
	indices: all the positions of the pseudo meas. within the SCP buffer

 OUTPUT PARAMETERS:
	scpps:	the position of the merged measurement within the SCP buffer

 RESTRICTIONS:
	

 SIDE EFFECTS:
	 

 METHOD: 
	The different arrays corresponding to the SCP variables within the
	given measurements are merged together and sorted accordingly to the
	variable SCP.TIME

 PROCEDURES USED:
       Common Block(s) or @ procedure(s):
               phtscp

 MODIFICATION HISTORY:
	Written by: C. Gabriel (ESA/VILSPA - SAI)		1996
	Revised and hdr written				September 1997 
	V6.5

(See /append_rp.pro)


BCKSUB_CALC

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	BCKSUB_CALC

 PURPOSE:
	Menu for PIA Background subtraction.
	This is a display dependant level menu in the PIA hierarchy.

	This routine should only be called by the PIA display menues
	and should not be called directly from the command line.

 CATEGORY:
	PIA - processing

 CALLING SEQUENCE:
	BCKSUB_CALC, signal, unc, flag, aver, sigma 

 INPUTS:
	signal: array containing the signals (SCP or SPD level)
	unc: array containing the uncertainty of signals (SCP or SPD level)
	flag: array containing the validity flag of signals (SCP or SPD level)
	
 OUTPUTS:
	aver: average of signals
	sigma: sigma of signals

 PROCEDURES USED:
	PIA LIB:
		weight_mean
	
 MODIFICATION HISTORY:
	 Extracted from PIA_BCKSUBT, because is called 
	 as a separate routine, eg pia_proc_gen (JAcosta)	April 1997
	 Keyword MEDIAN added, as a different way to 
	 project signals	(JAcosta)			August 1997

(See /bcksub_calc.pro)


C2P_IA2PIPE

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       C2P_IA2PIPE

 PURPOSE:
	Change the pixel order from IA (telemetry) order into pipeline SPD
	order

 CATEGORY:
	PIA - processing

 CALLING SEQUENCE:
       C2P_IA2PIPE, Iaarr, Piparr

 INPUTS:
       Iaarr 	: [4,x] array as C200 IA (telemetry) convention

 OUTPUTS:
       Piparr 	: [4,x] array as C200 pipeline convention

 PROCEDURES USED:
	None

 MODIFICATION HISTORY:
       Written by:	C. Gabriel
	Oct 95 Version 3.5
	Extended up to 5 dimensional arrays (CG)
	V6.3

(See /c2p_ia2pipe.pro)


C2P_PIPE2IA

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       C2P_PIPE2IA

 PURPOSE:
	Change the pixel order from pipeline SPD order into IA (telemetry)
	order

 CATEGORY:
	PIA - processing

 CALLING SEQUENCE:
       C2P_PIPE2IA, Piparr, Iaarr

 INPUTS:
       Piparr 	: [4,x] array as C200 pipeline convention

 OUTPUTS:
       Iaarr 	: [4,x] array as C200 IA (telemetry) convention

 PROCEDURES USED:
	None

 MODIFICATION HISTORY:
       Written by:	C. Gabriel
	Oct 95 Version 3.5
	Extended up to 5 dimensional arrays (CG)
	V6.3

(See /c2p_pipe2ia.pro)


CALC_APER

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	CALC_APER

 PURPOSE:
	This procedure calculates the image co-ordinates of each readout

 CATEGORY:
	PIA - processing

 CALLING SEQUENCE:
	CALC_APER, SunInst, Pixel, Point, Line, Chop, X, Y

 INPUTS:
	SubInst: PHT Subinstrument - 'C1', 'C2', 'P', 'S'
	Pixel: Pixel number - Only for PHT-C (anything otherwise)
	Point: Raster Point - Only for raster scans (anything otherwise)
	Line: Raster Line   - Only for raster scans (anything otherwise)
	Chop: Array of chopper positions

 OUTPUTS:
	X: x co-ordinate of aperture centre
	Y: y co-ordinate of aperture centre

 COMMON BLOCKS:
	raster_info

 PROCEDURES CALLED:
 	None

 MODIFICATION HISTORY:
	Written by:	Huw Morris
	Oct 95 Version 3.5

(See /calc_aper.pro)


CALC_STEP

[Previous Routine] [Next Routine] [List of Routines]

 NAME:
	CALC_STEP

 PURPOSE:
	This procedure calculates the step number within the chopper 
	cycle of each readout

 CATEGORY:
	 PIA - processing

 CALLING SEQUENCE:
	CALC_STEP, Step_No

 INPUTS:
	None

 OUTPUTS:
	Step_No: Array of step numbers (from 0 to Steps-1)

 COMMON BLOCKS:
	chop_info

 RESTRICTIONS:
	Assumes measurement started correctly and the chop_info common
	block is initialised

 PROCEDURE:
	This procedure calculates the time spent on each plateau, and
	from that, the time spent on each plateau in the cycle.
	The modulus of the measurement with the cycle time thus gives
	the point in the cycle of a particular measurement. 

 PROCEDURES USED:
	None

 MODIFICATION HISTORY:
	Written by:	Huw Morris
	Modified by:	C. Gabriel
	Oct 95 Version 3.5

(See /calc_step.pro)


CAL_INIT

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	CAL_INIT

 PURPOSE:
	To initialize all the parameters from Calibration G files

 CATEGORY:
	PIA - initialisation

 CALLING SEQUENCE:
	CAL_INIT

 INPUTS:
	(none)

 OUTPUTS:
	(none)

 COMMON BLOCKS:
	(none)
		
 PROCEDURE:
	Calibration G files are used eventually together with parameters
	which are direcly written into this routine and do not change
	frequently. 

 PROCEDURES USED:
	PIA LIB: darkcur_init
	         die_trans_init
	         phtcap_init
	         phtfilter_prop_init
		 read_chopcor
		 read_crelin
		 read_darkorb
		 read_fcsill
		 read_fcspow
		 read_flatfield
		 read_fluxconv
		 read_omega
		 read_pcpsf
		 read_resp
		 read_rlin
		 read_specal

 MODIFICATION HISTORY:
	Written by:	Carlos Gabriel, ESA/VILSPA	June 1999
	V7.4
       

(See /cal_init.pro)


CHANGE_TMPHDR

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	CHANGE_TMPHDR

 PURPOSE:
	Replaces in a temporary PHT PIA structure the element hdr

 CATEGORY:
	PIA - I/O

 CALLING SEQUENCE:
	change_tmphdr, tmpdata, type, newhdr, tmpout

 INPUTS:
	tmpdata: The (ERD,SRD,SCP,SPD) temporary structure
	type:	 Reduction level (ERD, SRD, ...)
	newhdr:	 The header for replacing tmpdata.hdr

	
 OUTPUTS:
	tmpout:  The new structure with the updated header
	
 SIDE EFFECTS:
	
 PROCEDURES USED:
	INTERNAL: 
	PIA_LIB:
		fill_erd, fill_srd, fill_scp, fill_spd, fill_aap
		pia_load_ierd, pia_load_isrd, pia_load_iscp, pia_load_ispd, 
		pia_load_iaap, pia_load_idynresp, dynresp_init, fill_dynresp, 
		dyncal_clear

 COMMON BLOCKS:
	pia_on_line	all internal buffers
	
 MODIFICATION HISTORY:
	Written by:	C.Gabriel (ESA/VILSPA)			January 1997
	V6.3
	Types dyncal added                  	(JAcosta-VILSPA) October 1998
	Type DYNR added 		    	(JAcosta-IAC)	 February 2000
	V8.2

(See /change_tmphdr.pro)


CHANGE_ZPLOT_PARAM

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       CHANGE_ZPLOT_PARAM

 PURPOSE:
	Change sequentially the Zplot parameters for overplotting, psym
	and color

 CATEGORY:
          PIA - processing

 CALLING SEQUENCE:
       CHANGE_ZPLOT_PARAM 

 INPUT:
	(none)

 COMMON BLOCKS:
	colour_indices
	pia_dspchz_cmn

 PROCEDURES USED:

 MODIFICATION HISTORY:
       Written by: C. Gabriel (ESA/VILSPA-SAI)		February 1996
	Change to predefined colors (CG) 		August 1999
	V8.0
			

(See /change_zplot_param.pro)


CHECK_CHOP

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	CHECK_CHOP

 PURPOSE:	
	Correct chopper position by signals which have bad flagged
	chopper information 

 CATEGORY:
	PIA - processing

 CALLING SEQUENCE:
	CHECK_CHOP, CHOP, CFLAG, NCHANGED

 INPUT PARAMETERS:
	chop:	The chopper positions of the ramps (SRD level)
	cflag:	The corresponding chopper flags
	

 OUTPUT:
	nchanged: the number of changed elements in input/output "chop" array 

 RESTRICTIONS:  

 METHOD:
	Chopper bad flagged signals get the chopper position of the 
	immediately following signal, if its information is reliable
	(normal reason for bad flag is given by problems with the update
	 in the readout chopper information) 

 MODIFICATION HISTORY:
	Written by: C. Gabriel (ESA/VILSPA)		September 1997
	V6.5

(See /check_chop.pro)


CHECK_STEP

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	CHECK_STEP

 PURPOSE:	
	Function to check the chopper steps vs chopper positions 

 CATEGORY:
	PIA - processing

 CALLING SEQUENCE:
	result = CHECK_STEP(chop, step, time, mode, cflag)

 INPUT PARAMETERS:
	chop:	The chopper positions of the ramps (SRD level)
	step:	The step positions of the ramps
	time:	The times of the ramps
	mode:	Structure containing:
			cste(nr of steps), cmod(chopper mode),cinc(increment)
			camp(amplitude), fcs(nr of active FCS)
	cflag:	Chopper position flag (same dimension as chop)
 
 KEYWORD INPUT:
	admn:	The admn name for more precise message in case of suspected
		time dropout

 OUTPUT:
	result:	the step mode calculated according to the chopper positions 

 RESTRICTIONS:  


 MODIFICATION HISTORY:
	Written by: C. Gabriel (ESA/VILSPA)		June 1997
	V6.4
	Use exact expected positions for each mode as
	mask - Do not use bad flagged positions (CG+JA) September 1997
	V6.5 
	Avoiding hundreds of reassigning messages (CG)  June 1998
	V7.2

(See /check_step.pro)


CHECK_UNC

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	CHECK_UNC

 PURPOSE:
	Checks an uncertainty array returning it setting positive values for
	uncertainties equal 0.

 CATEGORY:
	PIA - processing

 CALLING SEQUENCE:
	check_unc, values, unc

 INPUT:
	values:  Values array
	unc:	 Uncertainties array (same dimension as values)

 KEYWORD PARAMETERS:
	Verbose: For printing information
	Abs_min: Absolute minimum accepted for a distribution
	
 OUTPUT:
	(none)
	
 SIDE EFFECTS:
	Change the unc values, which were 0. by entry

 MODIFICATION HISTORY:
	Written by: J. Acosta (IAC) + C. Gabriel(ESA/SAI)	 September 1996
	Version 5.0 - Sept.96
	Abs_min Keyword added (CG)				 December 1997
	V6.6
	Assign stdev/SQRT(NPTS) as uncertainty in case all 
	unc are zero (JAc) 					August 1998
			

(See /check_unc.pro)


CHOP_FRCORR_FCT

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       CHOP_FRCORR_FCT

 PURPOSE:
       Return the correction factors and uncertainties corresponding to a
	given detector and chopper dwelltime, for the correction of signal
	losses due to chopping 

 CATEGORY:
       PIA - processing

 CALLING SEQUENCE:
       res = CHOP_FRCORR_FCT(det, dwelltime)

 INPUT PARAMETERS:
	DET:		String for detector used (eg. 'P1', 'C1' or 'C100')
	DWELLTIME:	Time spent on each chopper plateau (integer in sec.)
        
 OUTPUT:
       Returns a float array RES(npixel,2) with 
					RES(npixel,0)=Corr.factor for det pixels 
					RES(npixel,1)=Uncertainty 

 MODIFICATION HISTORY:
       Written by: C. Gabriel - ESA/VILSPA-SAI		January 1998
       Version 7.0

(See /chop_frcorr_fct.pro)


CHOP_FREQ_CORR

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       CHOP_FREQ_CORR

 PURPOSE:
       Perform the correction for signal losses in a chopped measurement to
	the subtracted values
       

 CATEGORY:
       PIA - processing

 CALLING SEQUENCE:
       CHOP_FREQ_CORR, tmpdata

 INPUT PARAMETERS:
	tmpdata: Background subtracted measurement 
        
 OUTPUT PARAMETERS:
       

 MODIFICATION HISTORY:
       Written by: J. Acosta / C. Gabriel		January 1998
       Version 7.0
	Problem with AAP case solved + systematic 
	 unc. not propagated but into hdr   (CG)	March 1998
	Bug correction dealing with the header (Jac)    April 1998
	V7.1

(See /chop_freq_corr.pro)


CHOP_INFO

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	CHOP_INFO

 PURPOSE:
	This is not an IDL routine as such, but contains the definition of the
	common block CHOP_INFO for inclusion into other routines.  By defining
	the common block in one place, the problem of conflicting definitions
	is avoided.

	This file is included into routines that need this common block with
	the single line (left justified)

				  @chop_info


	This file stores data from a single measurement about the chopper.

	CHOP_INFO contains the following variables:

	Mode : The chopper mode
       SubMode: The chopper submode
       Steps: The number of chopper steps
	Plat: The number of chopper plateaux
       Increment: The chopper increment

	Dest_Read: The number of destructive read-outs
	Int_Time: The integration time
	Chop_Amp: The chopper amplitude

	Start_Time: The start time of the measurement
	Current_Time: Array of times for each readout within the measurement

	Trans_Time_Meas: Chopper transition time for a measurement
	Trans_Time_Cal: Chopper transition time for a calibration
	Data_Red: Data Reduction 

 CATEGORY:
	PIA - common block

 MODIFICATION HISTORY:
	Written by:	Huw Morris
	Modified by:	C. Gabriel
	Oct 95 Version 3.5

(See /chop_info.pro)


CHOP_INFO_INIT

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       CHOP_INFO_INIT

 PURPOSE:
       This procedure reads the ERD and CS structures in order to
	initialises the chop_info common block

 CATEGORY:
	PIA - initialisation

 CALLING SEQUENCE:
       CHOP_INFO_INIT, Name

 INPUTS:
       Name: ERD admname as in the PHTERD structure

 OPTIONAL INPUTS
       Verbose: If set, print the parameters as they are read in.
       phterdt: temporary phterd structure
	cst: temporary phtcs structure
       csunit: Position of the corresponding Compact Status record

 OUTPUTS:
       None

 COMMON BLOCKS:
	adm
	phtcs
       phterd
	chop_info

 SIDE EFFECTS:
	The variables in the chop_info common block are initialised 

 PROCEDURES USED:
       PIA LIB: read_cs

 MODIFICATION HISTORY:
       Written by:	Huw Morris
	Modified by:	C. Gabriel
	Oct 95 Version 3.5
	Trying to cope with disturbed CS values (CG)	December 1995

(See /chop_info_init.pro)


CHOP_INFO_INIT_SPD

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       CHOP_INFO_INIT_SPD

 PURPOSE:
       This routine reads the SPD and CS to initialise the chop_info 
	common block

 CATEGORY:
	PIA - initialisation

 CALLING SEQUENCE:
       CHOP_INFO_INIT_SPD, Name

 INPUTS:
       Name: SPD admname as in the PHTSPD structure

 OPTIONAL INPUTS:
       Verbose: If set, print the parameters as they are read in.
       phtspdt: temporary phtspd structure
       csunit: Position of the corresponding Compact Status record

 OUTPUTS:
       None

 COMMON BLOCKS:
	adm
	phtcs
	phtspd
	chop_info

 PROCEDURES USED:
       PIA LIB: read_cs

 MODIFICATION HISTORY:
	Written by:	Carlos Gabriel (adopted from CHOP_INFO_INIT)
	Oct 95 Version 3.5

(See /chop_info_init_spd.pro)


CHOP_LEVELS

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	CHOP_LEVELS

 PURPOSE:
	This procedure returns averages and medians of chopper plateaux 
	per chopper level

 CATEGORY:
	PIA - processing

 CALLING SEQUENCE:
	CHOP_LEVELS, Tmpdata, Chplevl 

 INPUTS:
	Tmpdata: A structure containing data (SCP or SPD or AAP level)
	
 KEYWORD PARAMETERS:
	ISPD: (0:SCP; 1:SPD level; 2: AAP level)
 
 OUTPUTS:
	Chplevl: Structure containing
	      	name: measurement name
		level: 'SCP' or 'SPD' or 'AAP'
		aver: array (pixel #, step #) of averages 
		avun: array (pixel #, step #) of averages' uncertainties
		medi: array (pixel #, step #) of medians
		m1qu: array (pixel #, step #) of first quartiles
		m3qu: array (pixel #, step #) of third quartiles
		flag: flag array (pixel #, step #)

 PROCEDURES USED:
	PIA LIB: cp_disc
	         spd_disc
	         weight_mean
	
 MODIFICATION HISTORY:
	Written by:	C.Gabriel
	Oct 95 Version 3.5
	Modified to include subtraction at AAP level	  J.Acosta (June 1999)
	

(See /chop_levels.pro)


CHOP_PARAM

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	CHOP_PARAM

 PURPOSE:
	This is not an IDL routine as such, but contains the definition of the
	common block CHOP_INFO for inclusion into other routines.  By defining
	the common block in one place, the problem of conflicting definitions
	is avoided.

	This file is included into routines that need this common block with
	the single line (left justified)

				  @chop_param


	This common block contains the Chopper Position Conversion Parameters:
	
	A : Coefficients for the
	B : line approximation

	C : Parameters for initial conversion
	P : of TMDATA word to a voltage
	Q
	R

	Ang_Dev : Line deviation tables
	DU_DC

	Norm_Ang : Correction tables
	DU_ACD
	DU_ACI

	DCF1 : Parameters for FCS
	DCF2
	OF1
	OF2
	ACF1

 CATEGORY:
	PIA - common block

 MODIFICATION HISTORY:
	Written by:	Huw Morris
	Oct 95 Version 3.5

(See /chop_param.pro)


CHOP_PARAM_INIT

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	CHOP_PARAM_INIT

 PURPOSE:
	This proceude initialises the chop_param common block with 
       the TM constants

 CATEGORY:
	PIA - initialisation

 CALLING SEQUENCE:
	CHOP_PARAM_INIT

 INPUTS:
	None

 OUTPUTS:
	None

 COMMON BLOCKS
	chop_param

 SIDE EFFECTS:
	Alters the values defined in the chop_param common block

 PROCEDURES USED:
	None

 MODIFICATION HISTORY:
	Written by:	Huw Morris
	Modified by:	C. Gabriel
	Oct 95 Version 3.5

(See /chop_param_init.pro)


CHOP_POS

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	CHOP_POS

 PURPOSE:
	This procedure calculates the chopper postion from the telemetry data.

 CATEGORY:
	PIA - processing

 CALLING SEQUENCE:
	CHOP_POS, Conv_Chop, Step_No, FCS_No
 
 INPUTS:
	None

 OUTPUTS:
	Conv_Chop: Converted Chopper Position (Float Array)
	  For calibration measurements,
	  -180: FCS 1
	     0: COFOV
	   180: FCS 2
	Step_No: Step number within the chopper cycle (Int Array)
          From 1 - Plat
	FCS_No: Which calibration source is being pointed at (Int array)
	  -1: error
	   0: not a calibration measurement
	   1: FCS 1
	   2: FCS 2

 COMMON BLOCKS:
	chop_info
	chop_param

 PROCEDURES USED:
	PIA LIB: calc_step

 MODIFICATION HISTORY:
	Written by:	Huw Morris
	Modified by:	C. Gabriel
	Oct 95 Version 3.5

(See /chop_pos.pro)


CLA_INIT

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       cla_init
 PURPOSE:
       Initializes the structure PHTCLA defining the contents as
	a template structure PHTCLA_TYPE. It can be used for clearing
	the whole CLA structure, in case this should show as necessary. 
 CATEGORY:
	PIA - initialization

 CALLING SEQUENCE:
       CLA_INIT

 INPUT PARAMETERS:
	None       

 OUTPUT PARAMETERS: 
	None

 PROCEDURES USED:
       Common Block(s) or @ procedure(s):
               phtcla
               phtcla_init

 MODIFICATION HISTORY:
       Written by: W. M. Tai (DIAS)			May 1996
	modified for releasing the handle (WMT)		May 1996

(See /cla_init.pro)


COL_INDICES

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       COL_INDICES

 PURPOSE:
       This is not an IDL routine as such, but contains the definition of the
       common block COL_INDICES for inclusion into other routines.  By defining
       the common block in one place, the problem of conflicting definitions
       is avoided.

       This file is included into routines that need this common block with
       the single line (left justified)

                                 @col_indices

 	This file stores the RGB indices of various colours, allowing them
	to be referred to by name

 CATEGORY:
	PIA - common block

 MODIFICATION HISTORY:
	Written by:	Carlos Gabriel
	Oct 95 Version 3.5

(See /colour_indices.pro)


CONV_ANALOG

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       CONV_ANALOG

 PURPOSE:
       This procedure converts the analog part of an array hkdat of 
       an existing GEHK?.FITS into an string array hkout 
       containing the converted analog data

 CATEGORY:
	PIA - processing

 CALLING SEQUENCE:
       CONV_ANALOG, Idb, Idb_f_bounds, Hkdat, Hkout 

 INPUTS:
       Idb         :database array
       Idb_f_bounds:boundaries of STS and ANA block in the idb
       Hkdat       :array containing the fits data

 OUTPUTS:
       Hkout       :array, in which to store the converted data

 RESTRICTIONS:
       The part of this program dealing with action routines 
       isn't written yet
 
 PROCEDURE:
       Extract the relevant data for analog parameters from
       the input arrays and give it to the conv_curve function

 PROCEDURES USED:
       PIA LIB: conv_curve

 MODIFICATION HISTORY:
       Written by:	Andreas Karch
	Oct 95 Version 3.5

(See /conv_analog.pro)


CONV_CRE

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       CONV_CRE

 PURPOSE:
       This function converts the CRE Digitized Numbers DNs 
	(as from the telemetry) returning 
       the Output Voltages (in Volts) using the informations already gained 
	from the CRE Conversion Tables

 CATEGORY:
	PIA - processing

 CALLING SEQUENCE:
       Result = CONV_CRE(Rawdata, Det, Ordr, Csun)

 INPUTS:
       Rawdata	: Array containing the Digitized Numbers from the CRE
	Det	: Detector Identifier (two characters string)
       Ordr	: Measurement Order Number within 1 detector subsystem 
		  in the Compact Status
       Csun	: Compact Status Unit 

 OUTPUTS:
       Returns an array containing the CRE Voltages

 COMMON BLOCKS:
	phtcs
	phtdietrans

 PROCEDURE:
	Use the common PHTDIETRANS to compute the conversion together 
	with the selected Gain and Offset obtained from the CS
 
 PROCEDURES USED:
       None

 MODIFICATION HISTORY:
       Written by:	C. Gabriel
	Oct 95 Version 3.5
	U_off bug fixed - CG		February 1997
	V6.1

(See /conv_cre.pro)


CONV_CS

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       CONV_CS

 PURPOSE:
       This procedure converts extended housekeeping data from rawvalues 
	to physical values.

 CATEGORY:
	PIA - processing

 CALLING SEQUENCE:
       CONV_CS, File, Convcs 

 INPUTS:
       File: PHTCS_TYPE Array containing rawvalues

 OUTPUTS:
       Convcs: PHTCS_TYPE Array containing converted value

 PROCEDURE:
       Convert numbers to text strings with the help of 
       conversion arrays, interpreting the rawvalue as an
       array index.
       Convert all others with the formulas described in the
       'Converting Algorithms For Telemetry Data'        

 PROCEDURES USED:
       None

 MODIFICATION HISTORY:
       Written by:	Andreas Karch
	Modified by:	C. Gabriel
	Oct 95 Version 3.5
	New table values for change wheels (according to TR-PHT-0000 MP/25 
	 from November 27, 1995) + Meas.time=LONG INT	(CG)	January 1996

(See /conv_cs.pro)


CONV_CURVE

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       CONV_CURVE

 PURPOSE:
       This function converts idb element number i of the analog part  
       into an string array hkout containing the converted
       analog data

 CATEGORY:
	PIA - processing

 CALLING SEQUENCE:
       CONV_CURVE, Idb, C_tab, Hkdat, I 

 INPUTS:
       Idb         :database array
       I           :idb element number (must be in ANA part)
       Hkdat       :array containing the fits data
       C_tab       :conversion tables for element i
                    first part considers x-values, second part y

 OUTPUTS:
       None
 
 PROCEDURE:
       Add two one byte words to one two byte word, look
       for the bits dtermined by length and offset in the
       idb with the idb and function.
       Search for the two neighbours in the x part of the
       conversion table and find the right value by
       linear interpolation.        

 PROCEDURES USED:
       None

 MODIFICATION HISTORY:
       Written by:	Andreas Karch
	Oct 95 Version 3.5

(See /conv_curve.pro)


CONV_HK

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       CONV_HK

 PURPOSE:
       This procedure converts the housekeeping part of an GEHK?.FITS file
       into an string array hkout containing the converted data.

 CATEGORY:
	PIA - processing

 CALLING SEQUENCE:
       CONV_HK, Tdtnum, Idb, Hkout, Hkdat, Timestep, Idb_ar_table, $
	         Idb_ar_image

 INPUTS:
	Tdtnum      :TDT number corresponging to the housekeeping file
       Idb         :database array

 OUTPUTS:
       Hkout       :strarr(hk,x) containing converted data for each 
                    hk-parameter and each measurement
       Hkdat       :array containing the fits data
       Idb=starr(18,hk)  containing the 18 values of interest for each
                   hk-parameter from the idb_def table
           0:de_number 1:de_name 2:de_type 3:subcom_flag 4:modeflag
           5:monitor 6:max_slots 7:decomp 8:conv 9:limsel 10:limit
           11:memver 12:qlagen 13:extr_source 14:extr_ar
           15:location 16:offset 17:length
           18: handle with corresponding data
       Timestep(x) containing the time for each measurement
       Idb_ar_table and Idb_ar_image with informations about 
              action routines

 PROCEDURE:
       Read in fits data, find boundaries of analog part and status
       part and convert both parts in different subroutines        

 PROCEDURES USED:
       PIA LIB: get_boundaries
                conv_status
                conv_analog

 MODIFICATION HISTORY:
       Written by:	Andreas Karch
	Modified by:	C. Gabriel
	Oct 95 Version 3.5

(See /conv_hk.pro)


CONV_PROCDATE

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       CONV_PROCDATE

 PURPOSE:
	Convert a date from Sun systime() format into IDL !stime string format

 CATEGORY:
       PIA - miscellaneous

 CALLING SEQUENCE:
       CONV_PROCDATE, procdate, date

 INPUT:
	procdate	Date in sun systime format

 OUTPUT:
	date		Date in IDL !stime format

 PROCEDURES USED:

 MODIFICATION HISTORY:
       Written by: C. Gabriel (ESA/VILSPA-SAI)		January 1996
			

(See /conv_procdate.pro)


CONV_STATUS

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       CONV_STATUS

 PURPOSE:
       This procedure converts the status part of an array hkdat of 
       an existing GEHK?.FITS into an string array hkout 
       containing the converted status data

 CATEGORY:
	PIA - processing

 CALLING SEQUENCE:
       CONV_STATUS, Idb, Idb_f_bounds, Hkdat, Hkout 

 INPUTS:
       Idb         :database array
       Idb_f_bounds:boundaries of STS and ANA block in the idb
       Hkdat       :array containing the fits data

 OUTPUTS:
       Hkout       :array, in which to store the converted data

 RESTRICTIONS:
       The part of this program dealing with action routines 
       isn't written yet
 
 PROCEDURE:
       Extract the relevant data for status parameters from
       the input arrays and give it to the int_to_text function

 PROCEDURES USED:
       PIA LIB: int_to_text

 MODIFICATION HISTORY:
       Written by:	Andreas Karch
	Oct 95 Version 3.5

(See /conv_status.pro)


CONV_SUBS

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       CONV_SUBS

 PURPOSE:
       Convert the PHT subsystem number into the detector identifier string

 CATEGORY:
	PIA - processing

 CALLING SEQUENCE:
       Result = CONV_SUBS(Subs)

 INPUTS:
       Subs	: Subsystem number

 OUTPUTS:
       Returns a 2-character string as PHT detector identifier

 PROCEDURES USED:
       None

 MODIFICATION HISTORY:
       Written by:	C. Gabriel
	Oct 95 Version 3.5

(See /conv_subs.pro)


CORR_RESET_INT

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       CORR_RESET_INT

 PURPOSE:
	Apply the reset interval correction to an array

 CATEGORY:
	PIA - processing

 CALLING SEQUENCE:
       CORR_RESET_INT, IN_SIG, DET, INTT, DRED, OUT_SIG, CORR

 INPUT:
       IN_SIG:	signal input array
	DET:	detector (eg 'C1', 'C100', 'P1')
	INTT:	reset interval - INTEGER (PHT nomenclature: t_int=1/2^(INTT-7))
	DRED:	data reduction factor - INTEGER

 OUTPUT:
	OUT_SIG: corrected signal array
	CORR:	 structure (corr.a0, corr.a1) containing the used parameters

 KEYWORD:
	UNCERT:	error on in_sig by input - two elements array of syst.unc. by 
		output (from a0 and a1)

 RESTRICTIONS:
	(none)

 PROCEDURES USED: 
       Common Block(s) or @ procedure(s):
        phtintt_corr       

 MODIFICATION HISTORY:
       Written by: C. Gabriel  (ESA-SAI)		May 1997
	V6.3
	Returning also uncertainties (CG)		September 1997
	V6.5
	Allowing for larger data red as in table (CG)	December 1997
	V6.6
	UNCERT changed in output (CG)			March 1998
	Returning dummy corr structure if PHT-S		April 1988
	V7.1
	Bug for case of uncert=0 by entry fixed (CG)	May 1998
	V7.2

(See /corr_reset_int.pro)


CP_DISC

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       CP_DISC

 PURPOSE:
       Return a flag array with flag=2 for all the chopper plateaux
       discarded using the bitflag system

 CATEGORY:
	PIA - processing

 CALLING SEQUENCE:
       CP_DISC, Tmpdata, Flagarr

 INPUTS:
       Tmpdata: PHTSCP type temporary structure

 OUTPUTS:
       Flagarr: Flag array of dimensions (# pixels, # chopper plateaux)
		 # pixels does not include resistor and open pixel  

 COMMON BLOCKS:
	phtacc

 PROCEDURE:
       Use the SCP discard criteria within PHTACC to flag all chopper
       plateaux to be deselected        

 PROCEDURES USED:
       None

 MODIFICATION HISTORY:
	Written by: Carlos Gabriel - ESA-SAI
	Oct 95 Version 3.5
	Modified by CG - Sept. 96
	Version 5.0 - Sept. 96
	Changed according to bitflag system (CG)
	V7.4

(See /cp_disc.pro)


CP_DISCL

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       CP_DISCL

 PURPOSE:
       Return a flag array with flag=2 for all the chopper plateaux
       discarded  using the bitflag system

 CATEGORY:
	PIA - processing

 CALLING SEQUENCE:
       CP_DISCL, Tmpdata, Flagarr

 INPUTS:
       Tmpdata: PHTSCP type temporary structure

 OUTPUTS:
       Flagarr: Flag array of dimensions (# pixels, # chopper plateaux)
		 # pixels does not include resistor and open pixel  

 COMMON BLOCKS:
	phtacc

 PROCEDURE:
       Use the SCP discard criteria within PHTACC to flag all chopper
       plateaux to be deselected        

 PROCEDURES USED:
       None

 MODIFICATION HISTORY:
	Written by: Carlos Gabriel
	Oct 95 Version 3.5
	Changed according to bitflag system (CG)
	V7.4

(See /cp_discl.pro)


CS_INIT

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       CS_INIT

 PURPOSE:
       Initializes the structure PHTCS defining the contents as
	a template structure PHTCS_TYPE. It can be used for clearing
	the whole CS structure, in case this should show as necessary. 

 CATEGORY:
	PIA - initialisation

 CALLING SEQUENCE:
       CS_INIT

 INPUTS:
	None       

 OUTPUTS: 
	None

 COMMON BLOCKS:
	phtcs

 SIDE EFFECTS:
	Values in the phtcs common block are initialised

 PROCEDURES USED:
       PIA LIB: phtcs_init

 MODIFICATION HISTORY:
       Written by:	C. Gabriel
	Oct 95 Version 3.5

(See /cs_init.pro)


CURFIT

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	CURFIT

 PURPOSE:
	Non-linear least squares fit to a function of an
	arbitrary number of parameters.
	Function may be any non-linear function where
	the partial derivatives are known or can be approximated.

 CATEGORY:
	E2 - Curve and Surface Fitting

 CALLING SEQUENCE:
	yfit = curfit(x,y,w,a,sigmaa)
 INPUTS:
	X = Row vector of independent variables.
	Y = Row vector of dependent variable, same length as x.
	W = Row vector of weights, same length as x and y.
		For no weighting
		w(i) = 1., instrumental weighting w(i) =
		1./y(i), etc.
	A = Vector of nterms length containing the initial estimate
		for each parameter.  If A is double precision, calculations
		are performed in double precision, otherwise in single prec.

 KEYWORD PARAMTERS:
	funct = string containing the name of the fitting function.
	    Default = 'funct'
	quiet = 1 to suppress printing interation information.
	max_its = Maximum number of iterations the function will
		do before giving up. Default=1000.
	accept = Acceptance criterion for acceptable fit. 
		This number is equal to the relative change in the
		ChiSquare statistic from one iteration to the next. 
		Default=.00001

 OUTPUTS:
	A = Vector of parameters containing fit.
	Function result = YFIT = Vector of calculated
		values.
 OPTIONAL OUTPUT PARAMETERS:
	Sigmaa = Vector of standard deviations for parameters
		A.
	
 COMMON BLOCKS:
	NONE.
 SIDE EFFECTS:
	The function to be fit must be defined and called FUNCT.
	For an example see FUNCT in the IDL User's Libaray.
	Call to FUNCT is:
	FUNCT,X,A,F,PDER
 where:
	X = Vector of NPOINT independent variables, input.
	A = Vector of NTERMS function parameters, input.
	F = Vector of NPOINT values of function, y(i) = funct(x(i)), output.
	PDER = Array, (NPOINT, NTERMS), of partial derivatives of funct.
		PDER(I,J) = Derivative of function at ith point with
		respect to jth parameter.  Optional output parameter.
		PDER should not be calculated if parameter is not
		supplied in call (unless you want to waste some time).
 RESTRICTIONS:
	NONE.
 PROCEDURE:
	Copied from "CURFIT", least squares fit to a non-linear
	function, pages 237-239, Bevington, Data Reduction and Error
	Analysis for the Physical Sciences.

	"This method is the Gradient-expansion algorithm which
	compines the best features of the gradient search with
	the method of linearizing the fitting function."

	Iterations are perform until the chi square changes by
	only 0.001% or until 1000 iterations have been performed.

	The initial guess of the parameter values should be
	as close to the actual values as possible or the solution
	may not converge.

 MODIFICATION HISTORY:
	Written, DMS, RSI, September, 1982.
	Modified by D.L. Windt, AT&T Bell Labs, March, 1989.

(See /curfit.pro)


CURVEFIT

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	CURVEFIT

 PURPOSE:
	Non-linear least squares fit to a function of an arbitrary 
	number of parameters.  The function may be any non-linear 
	function where the partial derivatives are known or can be 
	approximated.

 CATEGORY:
	E2 - Curve and Surface Fitting.

 CALLING SEQUENCE:
	Result = CURVEFIT(X, Y, W, A, SIGMAA, FUNCTION_NAME = name)

 INPUTS:
	X:  A row vector of independent variables.

	Y:  A row vector of dependent variable, the same length as x.

	W:  A row vector of weights, the same length as x and y.
		For no weighting,
		w(i) = 1.0.
		For instrumental weighting,
		w(i) = 1.0/y(i), etc.

	A:  A vector, with as many elements as the number of terms, that 
	    contains the initial estimate for each parameter.  If A is double-
	    precision, calculations are performed in double precision, 
	    otherwise they are performed in single precision.

 KEYWORDS:
	FUNCTION_NAME:  The name of the function (actually, a procedure) to 
	fit.  If omitted, "FUNCT" is used. The procedure must be written as
	described under RESTRICTIONS, below.

 OUTPUTS:
	Returns a vector of calculated values.
	A:  A vector of parameters containing fit.

 OPTIONAL OUTPUT PARAMETERS:
	Sigmaa:  A vector of standard deviations for the parameters in A.
	
 COMMON BLOCKS:
	NONE.

 SIDE EFFECTS:
	None.

 RESTRICTIONS:
	The function to be fit must be defined and called FUNCT,
	unless the FUNCTION_NAME keyword is supplied.  This function,
	(actually written as a procedure) must accept values of
	X (the independent variable), and A (the fitted function's
	parameter values), and return F (the function's value at
	X), and PDER (a 2D array of partial derivatives).
	For an example, see FUNCT in the IDL User's Libaray.
	A call to FUNCT is entered as:
	FUNCT, X, A, F, PDER
 where:
	X = Vector of NPOINT independent variables, input.
	A = Vector of NTERMS function parameters, input.
	F = Vector of NPOINT values of function, y(i) = funct(x(i)), output.
	PDER = Array, (NPOINT, NTERMS), of partial derivatives of funct.
		PDER(I,J) = DErivative of function at ith point with
		respect to jth parameter.  Optional output parameter.
		PDER should not be calculated if the parameter is not
		supplied in call.

 PROCEDURE:
	Copied from "CURFIT", least squares fit to a non-linear
	function, pages 237-239, Bevington, Data Reduction and Error
	Analysis for the Physical Sciences.

	"This method is the Gradient-expansion algorithm which
	combines the best features of the gradient search with
	the method of linearizing the fitting function."

	Iterations are performed until the chi square changes by
	only 0.1% or until 20 iterations have been performed.

	The initial guess of the parameter values should be
	as close to the actual values as possible or the solution
	may not converge.

 EXAMPLE:
	pro gfunct, x, a, f, pder
	  f=a(0)*exp(a(1)*x)+a(2)
	  pder=findgen(10, 3)
	end

	pro fit_curve
	  x=float(indgen(10))
	  y=[12.0, 11.0,10.2,9.4,8.7,8.1,7.5,6.9,6.5,6.1]
	  w=1.0/y
	  a=[10.0,-0.1,2.0]
	  yfit=curvefit(x,y,w,a,sigmaa,function_name='gfunct')
	  print, yfit
	end

 MODIFICATION HISTORY:
	Written, DMS, RSI, September, 1982.
	Does not iterate if the first guess is good.  DMS, Oct, 1990.
	Added CALL_PROCEDURE to make the function's name a parameter.
		(Nov 1990)
	12/14/92 - modified to reflect the changes in the 1991
		   edition of Bevington (eq. II-27) (jiy-suggested by CreaSo)

(See /curpao.pro)


DARKCUR

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       DARKCUR

 PURPOSE:
	This routine subtracts the darkcurrent given in the signal array.

 CATEGORY:
       PIA - processing

 CALLING SEQUENCE:
       DARKCUR, Input_signal, Detector_name, Output_signal

 INPUTS:
       Input_signal: A 2-dim array. The first dim is the number of pixels
                     The pixel dim is {1, 1, 1, 9, 4, 64} for
                     detector {P1, P2, P3, C1, C2, SL}
                     Second dim is the number of signals
       Detector_name: One of these strings -- P1, P2, P3, C1, C2, SL

 OUTPUTS:
       Output_signal: Same dim as the input signal with the darkcurrent
                      correction

 COMMON BLOCKS:
       phtdarkcur

 RESTRICTIONS:
       The input detector string must be in upper case, or you get nothing!

 PROCEDURE:
       Use FXPAR to extract the keyword info

 PROCEDURES USED:
	ASTRO LIB: fxpar

 MODIFICATION HISTORY:
       Written by:	Wai-Ming Tai
	Modified by:	C. Gabriel
	Oct 95 Version 3.5 

(See /darkcur.pro)


DARKCUR_INIT

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       DARKCUR_INIT

 PURPOSE:
       Initializes the DARK CURRENT COMMON BLOCK

 CATEGORY:
	PIA - initialisation

 CALLING SEQUENCE:
       DARKCUR_INIT

 INPUTS:
       None

 OUTPUTS:
       None

 COMMON BLOCKS:
	phtdarkcur

 SIDE EFFECTS:
	The values in the phtdarkcur common blockare initialised

 PROCEDURES USED:
       ASTRO LIB: fxhread

 MODIFICATION HISTORY:
       Written by:	Wai-Ming Tai
	Modified by:	C. Gabriel
	added optional filename and change the openr to use /block
	esp for vms  (WMT)			March 1996
	Oct 95 Version 3.5
	free_lun instead of close (CG)		May 1996

(See /darkcur_init.pro)


DARKCUR_ORB

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	DARKCUR_ORB

 PURPOSE:
	Performs dark current subtraction on a measurement at SRD or SCP levels.

 CATEGORY:
	PIA - algorithms

 CALLING SEQUENCE:
	DARKCUR_ORB, tmpdata, DARK = dark, SCP = scp, NEWHEADER = newheader 
	
INPUTS

 KEYWORD PARAMETERS:
	DARK:		The dark current value subtracted
       SCP:    	If selected tmpdata is expected to be a SCP temporary 
			structure; if not it will be SRD
	NEWHEADER: Header of the measurement where info will be added. 
	PRO_RASTER:	Perform subtraction per raster point (overrides
			    PRO_MEAS and PRO_AOT)
	PRO_MEAS:	Perform subtraction per whole measurement (overrides 
			    PRO_AOT) 
	PRO_AOT:	Perform subtraction per AOT (default choice)
			   

 COMMON BLOCKS:
	phtdarkorb

 MODIFICATION HISTORY:
	Written by Jose ACOSTA (IAC/PIDT) and 
		   Carlos GABRIEL (ESA/VILSPA)			January 1998
	Bug correction for rasters	(JAc)			February 1998		
	V7.0
	No use of syst. unc. but -> header (CG)			March 1998
	V7.1
	Bug for extreme ITK cases fixed (CG)			May 1998
	V7.2
	Included Exposure Time dependency for SL dark current  
	  and better handling of KEYWORDS PRO_* (JAc)		August 1998

(See /darkcur_orb.pro)


DARKCUR_STR_INIT

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       DARKCUR_STR_INIT

 PURPOSE:
       Initializes the DARK CURRENT Structures

 CATEGORY:
	PIA - initialisation

 CALLING SEQUENCE:
       DARKCUR_STR_INIT

 INPUTS:
       None

 OUTPUTS:
       None

 PROCEDURES USED:
       None

 MODIFICATION HISTORY:
       Written by:	Carlos Gabriel
	Oct 95 Version 3.5
       Two more tags are included: ADMN and RESP  .-  J. Acosta March 1996
	Tags Proc_date, TRESET added  (JAcosta)			October 1997
	V6.5

(See /darkcur_str_init.pro)


DARKCUR_TIME

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	DARKCUR_TIME

 PURPOSE:
	Performs dark current subtraction on a measurement at SRD or SCP levels.

 CATEGORY:
	PIA - algorithms

 CALLING SEQUENCE:
	DARKCUR_ORB, tmpdata, DARK = dark, SCP = scp, NEWHEADER = newheader 
	
INPUTS

 KEYWORD PARAMETERS:
	DARK:		The dark current value subtracted
       SCP:    	If selected tmpdata is expected to be a SCP temporary 
			structure; if not it will be SRD
	NEWHEADER: Header of the measurement where info will be added. 
	PRO_RASTER:	Perform subtraction per raster point
	PRO_MEAS:	Same per whole measurement 

 COMMON BLOCKS:
	phtdarkorb

 MODIFICATION HISTORY:
	Written by Jose ACOSTA (IAC/PIDT) 			August 1998
	V7.2

(See /darkcur_time.pro)


DECODE_ADMN

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	DECODE_ADMN

 PURPOSE:
	This procedure decodes the PHT-IA administration name returning 
	a string.

 CATEGORY:
	PIA - processing  

 CALLING SEQUENCE:
       DECODE_ADMN, Admn, Decstr

 INPUTS:
       Admn  : An administration name as in pht###.admn                

 OUTPUTS:
       Decstr: A string containing the decoded explanation 

 KEYWORDS:
	Decstr_sh: A short version of the string

 PROCEDURES USED:
	None

 MODIFICATION HISTORY:
       Written by:	Carlos Gabriel
	Oct 95 Version 3.5
	Decoding also S for subtracted in admn
	Decoding also _LEG for raster leg
	Decoding also _CSTEP for chopper step
	Decoding also _y_z for Raster point separation case
	Keyword DECSTR_SH added (CG)				July 1997
	V6.4
	Extension for measurements' concatenations (CG)		November 1997
	V6.6
	Adding concatenation info (CG)				July 1998
	V7.2

(See /decode_admn.pro)


DECODE_CS2MEA

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       DECODE_CS2MEA

 PURPOSE:
       This is part of the pia_control panel support routines.
 	And therefore is designed entirely with the pia_control,
	pia_read_ext and pia_man_mea in mind.
	It is used for converting the compact information to
	the measurement information.

 CATEGORY:
       PIA - utilities

 CALLING SEQUENCE:
       DECODE_CS2MEA, meaname, string

 INPUT:
	meaname: the measurement name
	
 OUTPUT:
	string: the decoded string

 COMMON BLOCKS:
       phtcs

 PROCEDURES USED:
       PIA LIB:
	Astronomical Library:
 MODIFICATION HISTORY:
	Written by: Wai-Ming Tai (DIAS)			March 1996
	String bug fixed (pstafile) (CG)		July 1996
	Avoiding crash in case of record not found (CG) March 1998
	V7.1
	Confusing message avoided (CG)			September 1999
	V8.1

(See /decode_cs2mea.pro)


DECODE_FILETYPE

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       DECODE_FILETYPE

 PURPOSE:
       This is part of the pia_control panel support routines.
 	And therefore is designed entirely with the pia_control,
	pia_read_ext and pia_man_mea in mind.
	It is used for converting the file name to
	a more informatve information.

 CATEGORY:
       PIA - utilities

 CALLING SEQUENCE:
       DECODE_FILETYPE, FILENAME, OUTPUT-STRING

 INPUT:
	filename: the filename for decoding

 OUTPUT:
	output-string: the decoded string

 COMMON BLOCKS:

 PROCEDURES USED:
       PIA LIB:
	Astronomical Library:
 MODIFICATION HISTORY:
	Written by: Wai-Ming Tai (DIAS)			March 1996

(See /decode_filetype.pro)


DECODE_HDR2MEA

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       DECODE_HDR2MEA

 PURPOSE:
       This is part of the pia_control panel support routines.
 	And therefore is designed entirely with the pia_control,
	pia_read_ext and pia_man_mea in mind.
	It is used for converting the fits header to
	a more infromative information.
	It decodes the AOT name, the Object name and the ATTTYPE
	name ( pointing, tracking or raster).

 CATEGORY:
       PIA - utilities

 CALLING SEQUENCE:
       DECODE_HDR2MEA, HEADER, OUTPUT-STRING, PIA_NAME

 INPUT:
	header: the FITS header for decoding

 OUTPUT:
	output-string: the decoded string
	pia_name: name assigned by PIA, it can be modified by users.

 COMMON BLOCKS:

 PROCEDURES USED:
       PIA LIB:
	Astronomical Library:
 MODIFICATION HISTORY:
	Written by: Wai-Ming Tai (DIAS)			March 1996
	Measname added (CG)				May 1997
	V6.3

(See /decode_hdr2mea.pro)


DECODE_PIXF

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       DECODE_PIXF

 PURPOSE:
       Thie procedure extracts the information in the word --PIXF

 CATEGORY:
	PIA - processing

 CALLING SEQUENCE:
       DECODE_PIXF, Pixf

 INPUTS:
       Pixf - A word in the ERD files containing information in 5 bits
	ERD PIXF is defined in the following manner (see IDPD): 
	  1 bit - chopper on position (most significant bit)
	  1 bit - chopper sign
	  1 bit - readout status
	  1 bit - on-target flag
	  1 bit - automatic data reduction flag
	  10 bits - spare     ;;;;;;   don't ask me why?
	  1 bit - suspected data corruption flag (least significant bit)
	  

 OUTPUTS:
	None

 OPTIONAL OUTPUTS:
       Suspect:	Suspicious 		0:no	1:yes	-1:bad
       Chopon: 	Chopper on-position	0:no	1:yes	-1:bad       
       Chops: 		Chopper sign		0:-	1:+	-1:bad
       Rdstat:		Read-out status 	0:NDR	1:DR    -1:bad
       Otf:		On-target flag 		0:no	1:yes   -1:bad
       Autdr:		Auto data reduction 	0:no	1:yes   -1:bad

 PROCEDURES USED:
       None

 METHOD:
	Swap first to get all bits together and count nicely afterwards 

 MODIFICATION HISTORY:
       Written by:	Carlos Gabriel
	Oct 95 Version 3.5

(See /decode_pixf.pro)


DECODE_TDT2MEA

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       DECODE_TDT2MEA

 PURPOSE:
       This is part of the pia_control panel support routines.
 	And therefore is designed entirely with the pia_control,
	pia_read_ext and pia_man_mea in mind.
	It is used for converting the tdt measurement information
	a more infromative measurement information.

 CATEGORY:
       PIA - utilities

 CALLING SEQUENCE:
       DECODE_TDT2MEA, MEANAME, OUTPUT-STRING

 INPUT:
	MEANAME: the TDT measurement for decoding

 OUTPUT:
	output-string: the decoded string

 COMMON BLOCKS:

 PROCEDURES USED:
       PIA LIB:
	Astronomical Library:
 MODIFICATION HISTORY:
	Written by: Wai-Ming Tai (DIAS)			March 1996
	Special info added (CG)				July 1996
	Concatenated info added (CG)			November 1997
	V6.6
	Change for new concatenation nomenclature (CG)	July 1998
	V7.2

(See /decode_tdt2mea.pro)


DEC_ADMN

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	DEC_ADMN

 PURPOSE:
	Function to decode the PHT-IA administration name returning 
	a string.

 CATEGORY:
	PIA - processing  

 CALLING SEQUENCE:
       decstr = DEC_ADMN(Admn, decstr_sh=decstr_sh)

 INPUTS:
       Admn  : An administration name as in pht###.admn                

 OUTPUTS:
       Decstr: A string containing the decoded explanation 

 KEYWORDS:
	Decstr_sh: A short version of the string

 PROCEDURES USED:
	None

 MODIFICATION HISTORY:
       Written by:	Carlos Gabriel (ESA/SAI)	September 1997
	V6.5
	Returning same string if no correspondence
	 with expectations (CG)				October 1997
	V6.6
	Adding concatenation info (CG)			July 1998
	V7.2

(See /dec_admn.pro)


DEFAULT_RESPONSE

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       DEFAULT_RESPONSE

 PURPOSE:
       Calculate the expected default responsivity according to the orbital
	position
       

 CATEGORY:
       PIA - processing

 CALLING SEQUENCE:
       res = DEFAULT_RESPONSE(tmpdata)

 INPUT PARAMETERS:
	tmpdata: temp structure corresponding to SRD or SCP level 
        
 OUTPUT PARAMETERS:
       res: 		array of responsivities corresponding to each element in 
	     		tmpdata.tkey

 KEYWORD PARAMETERS:
	NEWHEADER: 	a changed header of the measurement
	PRO_AOT:	if set, central AOT position is taken for orbital
			position. Default is per measurement

 MODIFICATION HISTORY:
       Written by: C. Gabriel (ESA/VILSPA-SAI)			January 1998
       Version 7.0
	Bug for Resp pro AOT caused by dimensions fixed (CG)	September 1999
 V8.1

(See /default_response.pro)


DEG2GNO

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	DEG2GNO

 PURPOSE:
	DEG2GNO converts RA and DEC given in degrees into pixel indices I_RA
	and I_DEC in a gnonomic projection, assuming a projection center
	[RA0, DEC0]. Optionally, you can choose I_RA and I_DEC returned as
	floats.
	Pixel [0,0] is assumed to be in the lower left corner.

 CATEGORY:
       Astronomy.

 CALLING SEQUENCE:
	DEG2GNO, RA, DEC, RA0, DEC0, SCALE, N_RA, N_DEC, I_RA, I_DEC $
	   [, FLOAT = FLOAT ]

 INPUTS:
	RA:	Float scalar or array; specifying the right ascension(s)
		[degrees].
	DEC:	Float scalar or array; specifying the declination(s) [degrees].
	RA0:	Float scalar; specifying the projection center's right
		acsension [degrees].
	DEC0:	Float scalar; specifying the projection center's declination
		[degrees].
	SCALE:	Float scalar; specifying the number of pixels per degree.
		[degrees^-1].
	N_RA:	Int scalar; specifying the number of pixels in RA-direction.
	N_DEC:	Int scalar; specifying the number of pixels in DEC-direction.

 OPTIONAL INPUT PARAMETERS:
       None.

 OPTIONAL INPUT KEYWORDS:
	FLOAT:	If specified, I_RA and I_DEC are returned as floats.

 OUTPUTS:
	I_RA:	Int scalar or array; containing the index/indices of the
		specified position(s) in RA-direction.
	I_DEC:	Int scalar or array; containing the index/indices of the
		specified position(s) in DEC-direction.

 OPTIONAL OUTPUT PARAMETERS:
	None.

 OPTIONAL OUTPUT KEYWORDS:
	None.

 COMMON BLOCKS:
	None.

 SIDE EFFECTS:
       None.

 RESTRICTIONS:

 MODIFICATION HISTORY:
       created by: Stefan Bogun            MPIA Heidelberg
       	    March, 1995

(See /mapaap2drizzle.pro)


DEGLITCH

[Previous Routine] [Next Routine] [List of Routines]
  NAME:
	DEGLITCH

  PURPOSE:
	This procedure flags 'bad' ramps - those that are a specified 
	distance away from their neighbours.
	The ramps should be part of the same chopper position.

 CATEGORY:
	PIA - processing

 CALLING SEQUENCE:
	DEGLITCH, Slope, Error, Accept

 INPUTS:
	Slope: Array of ramp slopes within one chopper position
	Error: Error associated with each slope

 OUTPUTS:
	Accept: Array of flags corresponding to each slope
	  0: Accept
	  1: Not Accept

 COMMON BLOCKS:
	deglitch_param

 PROCEDURE:
	Take a local distribution and flag all points a certain number
	of standard deviations from the median. Advance the local 
	distribution. Reject all points that have been flagged a set
	number of times. 

 PROCEDURES USED
	None

 MODIFICATION HISTORY:
	Written by:	Huw Morris (adapted from Steve Guest's Fortran)
	Oct 95 Version 3.5
	Use for calculating the standard deviation all but the most
	away point (CG)			December 1995
	Problem derived from last change fixed 	December 1995
	Change taken away to have exactly same algorithm as OLP 	Feb 97
	V6.1 

(See /deglitch.pro)


DEGLITCH2

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	DEGLITCH2

 PURPOSE:
	Look for positive jumps in a ramp of a measurement returning 
	the ramp with jumps removed

 CATEGORY:
	PIA - processing

 CALLING SEQUENCE:
	DEGLITCH2, xin, yin, ydegl, FSIG=FSIG, ITER=ITER, MINP=MINP

 INPUTS:
	xin	: Array containing an x axis (e.g. time, position, etc) 
	Yin	: Array containing a ramp of read-outs 

 KEYWORDS:
	FSIG	: Sigmas' threshold for determining a jump
	ITER	: Number of iterations 
	MINP	: Minimum of points for applying the algorithm

 OUTPUTS:
	Ydegl	: Array containing the corrected y

 COMMON BLOCKS:
	degl_string
 RESTRICTIONS:

 PROCEDURES USED:
	None

 MODIFICATION HISTORY:
	Written by:	Carlos Gabriel (ESA/VILSPA-SAI)		December 1995
		(based partially on a routine by J.Acosta, IAC)
	Modified (last) by CG:
	Normalization fixed (CG)				February 1997
	Version 6.1
	Position within ramp info added to degltext (CG)	Januuary 1998
	V6.6

(See /deglitch2.pro)


DEGLITCH_ALL

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	DEGLITCH_ALL

 PURPOSE:
	This routine takes an array of ramps, and flags those which appear
	to be glitches in the data. Chopper plateaux are taken into account.

 CATEGORY:
	PIA - processing

 CALLING SEQUENCE:
	DEGLITCH_ALL, Slope, Step, RPID, Error, Sgdisc, Accept, [/SLICE_CHOPP], $
			[,/NOSLICE_RASTER]

 INPUTS:
	Slope: Array of ramp slopes
	Step:  Array of chopper steps (1-n)
	RPID:  2 BYTE-array of Raster Points ID
	Error: Error associated with each ramp
	SGDISC: Acceptance flag array (0=acc, all others discarded) 

 OUTPUTS:
	Accept: Array of flags corresponding to each slope
	  0:  Accept
	  1:  Not Accept

 KEYWORDS:
	slice_chopp: if set then perform deglitch on individual chopper
		     plateau. By default all chopper plateaus of the same 
		     step are used.

 RESTRICTIONS:
	The input arrays must be of the same dimension
 
 PROCEDURE:
	The ramps are separated into chopper/raster steps, then each step is
	deglitched separately using only the accepted points.

 PROCEDURES USED:
	PIA LIB: deglitch

 MODIFICATION HISTORY:
	Written by:	Huw Morris
	Modified by JA			 		November 96
	V5.4
	File header changes (CG)			February 1998
	V7.0
	

(See /deglitch_all.pro)


DEGLITCH_BASIC

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	DEGLITCH_BASIC

 PURPOSE:
	Look for positive jumps in a ramp of a measurement returning 
	the ramp with jumps removed

 CATEGORY:
	PIA - processing

 CALLING SEQUENCE:
	DEGLITCH_BASIC, xin, yin, ydegl, FSIG=FSIG, ITER=ITER, MINP=MINP

 INPUTS:
	xin	: Array containing an x axis (e.g. time, position, etc) 
	Yin	: Array containing a ramp of read-outs 

 KEYWORDS:
	FSIG	: Sigmas' threshold for determining a jump
	ITER	: Number of iterations 
	MINP	: Minimum of points for applying the algorithm

 OUTPUTS:
	Ydegl	: Array containing the corrected y

 COMMON BLOCKS:
	degl_string
 RESTRICTIONS:

 PROCEDURES USED:
	None

 MODIFICATION HISTORY:
	Original routine "deglitch2.pro"
	Written by:	Carlos Gabriel (ESA/VILSPA-SAI)		December 1995
		(based partially on a routine by J.Acosta, IAC)
	Modified (last) by CG:
	Normalization fixed (CG)				February 1997
	Version 6.1
	Position within ramp info added to degltext (CG)	Januuary 1998
	V6.6
	
	Renamed to deglitch_basic after simplification by
	Jose Acosta (IAC)					May 1999
	V7.4
	Preventing for a case with all differences equal (CG)	July 1999
	V8.0 

(See /deglitch_basic.pro)


DEGLITCH_CHANGE[1]

[Previous Routine] [Next Routine] [List of Routines]
  NAME:
	DEGLITCH_CHANGE

  PURPOSE:
	Event handler for Deglitch_Change

  CATEGORY:
	PIA - graphics

  MODIFICATION HISTORY
	Written by:	Huw Morris
	Modified by:	C. Gabriel
	Oct 95 Version 3.5
	Deglitching taking into account RPID!  (CG)	      June 1996
	Discarded signals are not considered for 
	deglitching, added input another argument  (JA)       March 1997
	No upper limit for local distribution (CG)	      June 1997
	V6.3
	Shows in red former discarded points, in blue 
		new ones (CG)				      January 1998
	V6.6
	Use of /modal as prescribed for IDL >=5.0 (CG)	      January 1999
	V7.3

(See /deglitch_change.pro)


DEGLITCH_CHANGE[2]

[Previous Routine] [Next Routine] [List of Routines]

  NAME:
	DEGLITCH_CHANGE

  PURPOSE:
	Allows the user to interactively alter the deglitching parameters

  CATEGORY:
	PIA - graphics

  CALLING SEQUENCE:
	DEGLITCH_CHANGE, Time, Slope, Chopstep, RPID, Error, Sgdisc, Accept

  INPUTS:
	Time	: Array of input times (corresponding to slope)
	Slope   : Array of input slopes
	Chopstep: Corresponding array of chopper steps
	RPID	: Corresponding array (2 BYTE-Arr) of Raster Points ID
	Error   : Corresponding array of slope errors
	Sgdisc  : Corresponding array with discarded signals 

  OUTPUTS:
	Accept  : Array of the status of each slope:
	  0 - Accept
	  1 - Reject

  COMMON BLOCKS:
	deglitch_param

  SIDE EFFECTS:
	Values in the deglitch_param common block are altered.

  PROCEDURES USED:
	PIA LIB:  Acknowledge
	          pia_plot
	          pia_xplot
	INTERNAL: deglitch_change_event

  MODIFICATION HISTORY:
	Written by:	Huw Morris
	Modified by:	C. Gabriel
	Oct 95 Version 3.5
	Accept & quit implemented (CG)			December 1995
	Time = input parameter -> time x-axis (CG)	January 1996

(See /deglitch_change.pro)


DEGLITCH_PARAM

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	DEGLITCH_PARAM

 PURPOSE:
	This is not an IDL routine as such, but contains the definition of the
	common block DEGLITCH_PARAM for inclusion into other routines.  By 
	defining the common block in one place, the problem of conflicting 
	definitions is avoided.

	This file is included into routines that need this common block with
	the single line (left justified)

				  @deglitch_param

	This file stores the parameters for the deglitching routine:
	
	Min_Deglitch: Minimum number of slopes required to perform the
	              filtering algorithm
	Max_Error: Maximum error before a point is flagged
	Max_Iter: Maximum number of iterations to perform
	Num_Bad: Number of times a pixel has to be flagged before it is
	         rejected
	Num_Local: Number of slopes in the local distribution
	Num_Sigma: Number of sigmas from the median a slope must be
	           to be flagged.
	Num_Step: Number of points to step
	Per_Chop: Set for deglitch per chopper plateaux 
	Degl_Clip: If not equal 0, maximum/minimum clipping is used for 
		   determining sigma

 CATEGORY:
	PIA - common block

 MODIFICATION HISTORY:
	Written by:	Huw Morris
	Extended by CG		November 1996
	V5.x

(See /deglitch_param.pro)


DEGLITCH_PARAM_INIT

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	DEGLITCH_PARAM_INIT

 PURPOSE:
	Initialise the deglitch_param common block

 CATEGORY:
	PIA - initialisation

 CALLING SEQUENCE
	DEGLITCH_PARAM_INIT

 INPUTS:
	None

 OUTPUTS:
 	None

 COMMON BLOCKS:
	deglitch_param

 SIDE EFFECTS:
	The values of the deglitch_param common block are initialised

 PROCEDURES USED:
 	None

 MODIFICATION HISTORY:
	Written by:	Huw Morris
	Modified by CG		November 1996
	V5.x
	Max/Min clipping set as default (CG)		Aug. 1999
	V8.0 

(See /deglitch_param_init.pro)


DEGL_RAMPS

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	DEGL_RAMPS

 PURPOSE:
	Deglitch ramps of a measurement returning 
	the corrected ramps

 CATEGORY:
	PIA - processing

 CALLING SEQUENCE:
	DEGL_RAMPS, XALL, YALL, ERD_DISC, RAMPEND, DEGLFLAG, DEGLINFO

 INPUTS:
	Xall	: Array containing the independent variable [t]  (same size)
	Yall	: Array containing values of read-outs from a measurement [V]
	Erd_disc: Array containing flags (0=to be used, 1=not to be used)
	Rampend	: Array containing the end of integration ramps (before ramp
		   splitting)
	Tint	: On chip integration time applied in the measurement
	

 OUTPUTS:
	Degflag	: Array containing flags (0=undisturbed signal, 5=glitch)

 RESTRICTIONS:
	Yall, Xall, ERD_DISC must have the same number of elements

 PROCEDURES USED:
	PIA source:
		deglitch_basic

 COMMON BLOCKS:
	degl_ramps_cmn

 MODIFICATION HISTORY:
	Written by:	Carlos Gabriel (ESA/VILSPA-SAI)	        December 1995
	Modifications by I.Heinrichsen (MPIK) and CG
	Version 5.0					        August 1996
	Flag coding included and use of rampend (JAcosta)	May 1999
	V7.4

(See /degl_ramps.pro)


DEGL_RAMPS_INIT

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	DEGL_RAMPS_INIT

 PURPOSE:
	Deglitch ramps common initializer

 CATEGORY:
	PIA - initializing

 CALLING SEQUENCE:
	DEGL_RAMPS_INIT

 INPUTS:
	(none)

 OUTPUTS:
	(none)

 RESTRICTIONS:
	(none)

 COMMON BLOCKS:
	degl_ramps_cmn

 MODIFICATION HISTORY:
	Written by:	Carlos Gabriel (ESA/VILSPA-SAI)	August 1996

(See /degl_ramps_init.pro)


DELCHR

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       DELCHR
 PURPOSE:
       Delete all occurrences of a character from a text string.
 CATEGORY:
 CALLING SEQUENCE:
       new = delchr(old, char)
 INPUTS:
       old = original text string.     in
       char = character to delete.     in
 KEYWORD PARAMETERS:
 OUTPUTS:
       new = resulting string.         out
 COMMON BLOCKS:
 NOTES:
 MODIFICATION HISTORY:
       R. Sterner.  5 Jul, 1988.
       Johns Hopkins Applied Physics Lab.
       RES 11 Sep, 1989 --- converted to SUN.
       R. Sterner, 27 Jan, 1993 --- dropped reference to array.

 Copyright (C) 1988, Johns Hopkins University/Applied Physics Laboratory
 This software may be used, copied, or redistributed as long as it is not
 sold and this copyright notice is reproduced on each copy made.  This
 routine is provided as is without any express or implied warranties
 whatsoever.  Other limitations apply as described in the file disclaimer.txt.

(See /mapaap2drizzle.pro)


DER_SCPHDR

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       DER_SCPHDR

 PURPOSE:
	Derive a SCP Header file, adding to the SRD header (SRDHDR) 
	keywords indicating signal selection criteriae for SCP derivation.

 CATEGORY:
	PIA - processing

 CALLING SEQUENCE:
       DER_SCPHDR, Srdhdr, Scphdr

 INPUTS:
       Srdhdr 	: SRD-header

 OUTPUTS:
       Scphdr 	: SCP-header

 COMMON BLOCKS:
	phtacc

 PROCEDURES USED: 
	None

 MODIFICATION HISTORY:
	Written by:	Carlos Gabriel
	Modified by: 	Wai-Ming Tai
	Oct 95 Version 3.5
	Comment changed to indicate SCP level (CG)		March 1996

(See /der_scphdr.pro)


DER_SHDR

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       DER_SHDR

 PURPOSE:
	Derive a SRD Header file, adding to the ERD header (ERDHDR) 
	keywords indicating read-out selection criteriae for SRD derivation.

 CATEGORY:
	PIA - processing

 CALLING SEQUENCE:
       DER_SHDR, Erdhdr, Srdhdr

 INPUTS:
       Erdhdr 	: ERD-header
	Ndeg	: Degree of the polynomial used to perform ramp fitting

 OUTPUTS:
       Srdhdr 	: SRD-header

 COMMON BLOCKS:
	phtacc

 PROCEDURES USED: 
	None

 MODIFICATION HISTORY:
       Written by:	Carlos Gabriel
	Modification history: 
	ERD keywords taken out (CG) - December 1996
	V5.5	
	Ramp subdivision info added (CG)	March 1997
	V6.2
	Bug for first NDR acc fixed (CG)	September 1997
	V6.5
	Bug on type caused by new comment lines in ERD
	 original files fixed	(CG)		September 1999
	V8.0

(See /der_shdr.pro)


DER_SPDHDR

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       DER_SPDHDR

 PURPOSE:
	Derive a SPD Header file, adding to the SCP header (SCPHDR) 
	keywords indicating signal selection criteriae for SPD derivation.

 CATEGORY:
	PIA - processing

 CALLING SEQUENCE:
       DER_SPDHDR, Scphdr, Spdhdr

 INPUTS:
       Scphdr 	: SCP-header

 KEYWORD PARAMETERS:
	USRMSG	: Set this for a user message

 OUTPUTS:
       Spdhdr 	: SPD-header

 COMMON BLOCKS:
	phtacc

 PROCEDURES USED:
	None 

 MODIFICATION HISTORY:
       Written by Carlos Gabriel
	Oct 95 Version 3.5
	Comment changed indicating SPD level (CG)		March 1996

(See /der_spdhdr.pro)


DET_CALFILE

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	DET_CALFILE

 PURPOSE:
	Determines which Calibration File has to be used according to the
	measurement time

 CATEGORY:
	PIA - I/O

 CALLING SEQUENCE:
	det_calfile, orig_name, meas_time, tmp_name, error=error

 INPUT PARAMETERS:
	orig_name: The original calibration filename without extension
	meas_time: The measurement time for which calibration numbers are needed


 OUTPUT PARAMETERS:
	tmp_name:  The actual calibration file to be used

 RESTRICTIONS:

 METHOD:

 PROCEDURES USED:
       Astronomical Library:
		date_conv
		fxbopen
               fxbread

 MODIFICATION HISTORY:
	Written by: C. Gabriel - ESA-SAI	September 96

(See /det_calfile.pro)


DIE_TRANS_INIT

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	DIE_TRANS_INIT

 PURPOSE:
	To put the relevant parameters for CRE conversion into the
	common block phtdietrans

 CATEGORY:
	PIA - initialisation

 CALLING SEQUENCE:
	DIE_TRANS_INIT

 INPUTS:
	None

 OUTPUTS:
	None

 COMMON BLOCKS:
	phtdietrans

 PROCEDURE:
	The calibration G files PDIE1TRANS and PDIE2TRANS are used 
	together with the compact status to put 4 of the 5 parameters
	needed for the CRE conversion into the common PHTDIETRANS. 
	This way simplifies applying different numbers for converting,
	then just the common has to be changed.

 PROCEDURES USED:
	ASTRO LIB: fxbopen
	           fxbread
	           fxbclose
	           boost_array

 MODIFICATION HISTORY:
	Written by Carlos Gabriel
	Oct 95 Version 3.5

(See /die_trans_init.pro)


DO_CORR_RESETINT

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       DO_CORR_RESETINT

 PURPOSE:
       Perform the reset interval correction for a measurement, at
	SRD or SCP level.

 CATEGORY:
       Signal corrections

 CALLING SEQUENCE:
       DO_CORR_RESETINT, tmpdata, newheader, SCP= scp, INFO= info

 INPUTS:
       tmpdata: Temporary data structure at SRD or SCP level
 KEYWORD PARAMETERS:
       SCP:  If set then the measurement is
       INFO:   A text containing info about the success or not of the correction

 COMMON BLOCKS:

 RESTRICTIONS:
       TMPDATA must be a valid element of PHTSRD/PHTSCP temporary structure

 PROCEDURES USED:
       PIA LIB:
               give_cs
		corr_reset_int
       ASTRO LIB:
               fxpar

 MODIFICATION HISTORY:
       Written by: J.Acosta (ISO Soc)               November 1997
       V6.6
	Systematic unc. not propagated but into hdr   (CG)	March 1998
	V7.1
	Writing [-1.,-1.] for undefined uncertainties (CG)
	 and avoiding division by 0.				July 1998
	V7.2
	Changed according to bitflag system (CG)
       V7.4

(See /do_corr_resetint.pro)


DO_DEGLITCH

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	DO_DEGLITCH

 PURPOSE:
	Apply deglitching procedure to a phtsrd structure 

 CATEGORY:
	PIA - processing

 CALLING SEQUENCE:
	DO_DEGLITCH, Tmpdata, Tmphdr, sig_disc, Degl_acc [,/ENCODE_FLAG] $ 
              [,GROUP=group]

 INPUTS:
	Tmpdata:  A PHTsrd temporary structure
	Sig_disc: Array with discarding flags
	Tmphdr:	  The temporary header
	
 OUTPUTS:
	Tmphdr:	  The updated temporary header 
	Degl_acc: A 2-dim index array of deglitched signals
	
 COMMON BLOCKS:
	deglitch_param

 RESTRICTIONS:
	tmpdata must be a temporary PHT SRD structure
	
 PROCEDURES CALLED:
	PIA LIB: deglitch_param_init
	         deglitch_all
	Astrolib: FXADDPAR
	
 MODIFICATION HISTORY:
	Written by:	Carlos Gabriel
	Oct 95 Version 3.5
	Not initializing the deglitch_param common if already existent (CG)
								December 1995
	Call to deglitch_all including RPID
	Sig_disc array included as input to avoid discarded
	signals	(JA)						March 1997
	Use of FXADDPAR (CG)					July 1997
	V6.4
	tmpdata.flag is not modified, degl. flag is 
       in degl_acc (JA)  					February 1998
	V7.1

(See /do_deglitch.pro)


ERD_INIT

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       ERD_INIT

 PURPOSE:
       Re-Initializes the structure PHTERD defining the contents as
	a template structure PHTERD_TYPE. It can be used for clearing
	the whole ERD structure, in case this should show as necessary. 

 CATEGORY:
	PIA - initialisation

 CALLING SEQUENCE:
       ERD_INIT

 INPUTS:
	None       

 OUTPUTS: 
	None

 KEYWORDS:
	Index:	If set, only those will be deleted from buffer

 COMMON BLOCKS:
	phterd
	
 PROCEDURES USED:

 MODIFICATION HISTORY:
       Written by:	Carlos Gabriel
	use erd_first_handle and erd_last_handle (WMT)		May 1996
	Oct 95 Version 3.5
	Keyword index for clearing set of records added (CG+JA)	May 1997
	V6.3

(See /erd_init.pro)


EXTR_NUM

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	EXTR_NUM

 PURPOSE:
	Extract numerical part from string. 
	The function facilitates if float or exponential
	numbers are hidden within names and the exact position
	is not known.

 CATEGORY:
	PIA - processing

 CALLING SEQUENCE:
	EXTR_NUM(string)

 INPUT:
	string:		(string) any string

 KEYWORD PARAMETERS:	
	none

 OUTPUT:
	function:	(string) containing the first contiguous
			numerical expression, icluding + and - 
			signs and characters 'E' and 'D' in both,
			upper- and lowercase.

 COMMON BLOCKS:

 RESTRICTIONS:

 PROCEDURES USED:	
	IS_NUM()

 EXAMPLE:
	IDL> print, extr_num('P_3.29')
	3.29



 MODIFICATION HISTORY:
	Written by:	Bernhard Schulz
	21/03/97	first version		BS

(See /extr_num.pro)


FCSPOW_STR_INIT

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       FCSPOW_STR_INIT

 PURPOSE:
       Initializes the structures corresponding to the FCS Power Tables

 CATEGORY:
	PIA - initialisation

 CALLING SEQUENCE:
       FCSPOW_STR_INIT

 INPUTS:
       None

 OUTPUTS:
       None

 PROCEDURES USED:
       None

 MODIFICATION HISTORY:
       Written by Carlos Gabriel
	Oct 95 Version 3.5
	Structure changed	CG	October 1995
	Structure extension	CG	December 1995
	Structure extension (TDTNR & PSF_COR) JAcosta   (June 1996)

(See /fcspow_str_init.pro)


FCSPRE_STR_INIT

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       FCSPRE_STR_INIT

 PURPOSE:
       Initializes the structures corresponding to the FCS Pre-reduced
	Signal Table

 CATEGORY:
	PIA - initialisation

 CALLING SEQUENCE:
       FCSPRE_STR_INIT

 INPUTS:
       None

 OUTPUTS:
       None

 PROCEDURES USED:
       None

 MODIFICATION HISTORY:
       Written by Carlos Gabriel	October 1995
	TDTnr now a string (CG)		June 1996

(See /fcspre_str_init.pro)


FCS_BUFFER_VIEW

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       FCS_BUFFER_VIEW

 PURPOSE:
	View the FCS POWER data array which is either a CALG array
       or just a data array similar to the CALG array format.

 CATEGORY:
	PIA - graphics

 CALLING SEQUENCE:
       FCS_BUFFER_VIEW, Buffer, Detector, First_column, 
	  Fcsa, Trsa, Filters, PREFIX=PREFIX

 INPUTS:
	Buffer  : A 45 x (detectors filters) x 2 x 2 array of float
       Detector: character string of 'P1', 'P2', 'P3, 'C100' and 'C200'
       First_Column: FCS Power table, float array of 45 elements
       Fcsa    : an integer value of either 0 or 1
       Trsa    : an integer value of either 0 or 1
       Filters : a string array of filters' name

 OUTPUTS:
	None

 OPTIONAL OUTPUTS:
       Prefix: a character string for the display window title prefix

 PROCEDURES USED:
	None

 MODIFICATION HISTORY:
       Written by:	Wai-Min Tai
	Oct 95 Version 3.5

(See /fcs_buffer_view.pro)


FCS_POW_CONV

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	FCS_POW_CONV

 PURPOSE:
	Function to convert fcs powers to physical units (mW)

 CATEGORY:
	PIA - processing

 CALLING SEQUENCE:
	FCS_POW_CONV, Raw_fcs

 INPUTS:
	Raw_fcs  : The raw fcs power value as extracted from telemetry

 OUTPUT:
	Returns the FCS power converted to physical units (mW)

 PROCEDURES USED:
	None

 MODIFICATION HISTORY:
	Written by:	Wai-Ming Tai
	Oct 95 Version 3.5

(See /fcs_pow_conv.pro)


FFMAP

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	FFMAP

 PURPOSE:
	Compute flat fielding parameters of C100, C200 maps

 CATEGORY:
	PIA - processing

 CALLING SEQUENCE:
	FFMAP, gridsize, ndist, x_coord, y_coord, dwel_xpd, bright, uncert, $
		flag, ff, ERROR=ERROR, p_map_expose=p_map_expose 

 INPUTS:
	GRIDSIZE	The map gridsize [FLTARR(2)]

	NDIST		Distance of map pixel centre to detector pixel centre
				in units of map pixel dimensions [FLTARR(2)]

	X_COORD		Map x-coordinates of input data
			as calculated by PIA_MAPSET [FLTARR(npixels,n)]

	Y_COORD		Map y-coordinates of input data
			as calculated by PIA_MAPSET

	DWEL_XPD	Dwell time over detector area [FLTARR(npixels,n)]

	BRIGHT		Brightness density array [FLTARR(npixels,n)]

	UNCERT		Brightnes density uncertainty array [FLTARR(npixels,n)]

	FLAG		Flag array [FLTARR(npixels,n)]
 

 KEYWORD PARAMETERS:
	ERROR		Returns an error status:
			0 = no error
			1 = error: output arguments are not correct

 OUTPUTS:
	FF		The flat field correction factors normalized 
				to the average of used pixels


 MODIFICATION HISTORY:
	Written by: 	C. Gabriel, ESA/VILSPA-SAI	March 1996
	Modified by CG
	V5.x - November 96

(See /ffmap.pro)


FFMAP_SIMPLE

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	FFMAP_SIMPLE

 PURPOSE:
	Compute flat fielding parameters of C100, C200 maps assuming perfect
		P32-AOT performance (no use of astronomical coordinates)

 CATEGORY:
	PIA - processing

 CALLING SEQUENCE:
	FFMAP_SIMPLE, dim, y_low, z_low, cover, dwel, ratio, $
			bright, uncert, flag, ff, ERROR=ERROR 
 INPUTS:
	DIM		The map gridsize [FLTARR(2)]

	Y_LOW		First map pixel (in Y-direction) covered by detector 
			pixel [FLTARR(npixels,n)]

	Z_LOW		First map pixel (in Z-direction) covered by detector 
			pixel [FLTARR(npixels,n)]

	COVER		Number of grid points covered by one detector pixel
		
	DWEL		Dwell time [FLTARR(npixels,n)]

	RATIO		Ratio of map pixel over detector pixel area

	BRIGHT		Brightness density array [FLTARR(npixels,n)]

	UNCERT		Brightnes density uncertainty array [FLTARR(npixels,n)]

	FLAG		Flag array [FLTARR(npixels,n)]
 

 KEYWORD PARAMETERS:
	ERROR		Returns an error status:
			0 = no error
			1 = error: output arguments are not correct

 OUTPUTS:
	FF		The flat field correction factors normalized 
				to the average of the pixels used


 MODIFICATION HISTORY:
	Written by: 	C. Gabriel, ESA/VILSPA-SAI	March 1996
	Modified by CG	(last: November 1996)
	V5.x

(See /ffmap_simple.pro)


FF_BCK

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	FF_BCK

 PURPOSE:
	Flat fielding using a map background given by flagged points. 

 CATEGORY:
	PIA - processing

 CALLING SEQUENCE:
	ff_BCK, mnbr, ff_bright, FLAG=flag, FF=ff, error=error

 INPUT:
	mnbr:	the original brightness array

 OUTPUT:
	ff_bright: the flatfielded array

 INPUT KEYWORDS:
	FLAG:	the array (same size as mnbr) with 1 for selected points

 OUTPUT KEYWORDS:
	FF:	the calculated flat field factors
	ERROR:	0=OK, 1=failed
	
 COMMON BLOCKS:
	none

 PROCEDURES USED:
	none
	
 MODIFICATION HISTORY:
	Written by:	C.Gabriel (ESA/VILSPA-SAI)	September 1997
	Version 6.5

(See /ff_bck.pro)


FF_MED_SMOOTH

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	FF_MED_SMOOTH

 PURPOSE:
	Median filtering and smoothing routine for map background. 

 CATEGORY:
	PIA - processing

 CALLING SEQUENCE:
	ff_med_smooth, mnbr, ff_bright, FLAG=flag, FF=ff, $
		MED_WIDTH=MED_WIDTH, SMOOTH_WIDTH=SMOOTH_WIDTH, NO_FF=NO_FF
	
 COMMON BLOCKS:
	none

 PROCEDURES USED:
	none
	
 MODIFICATION HISTORY:
	Written by:	C.Gabriel (ESA/VILSPA-SAI)	September 1997
	Version 6.5

(See /ff_med_smooth.pro)


FILL_AAP

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       FILL_AAP

 PURPOSE:
	FILLS a temporary structure into the dynamical structure PHTAAP  

 CATEGORY:
	PIA - I/O

 CALLING SEQUENCE:
       FILL_AAP, tmp, newheader, REPLACE=replace

 INPUT:
       tmp 	: AAP like temporary structure

 OPTIONAL INPUT:
	newheader: Modified header 
	REPLACE : IF set (different to 0) put structure into this PHTAAP position

 RESTRICTIONS:
       tmp must be a valid phtaap like temporary structure

 PROCEDURES USED: 
       Common Block(s) or @ procedure(s):
               phtaap

 MODIFICATION HISTORY:
       Written by: C. Gabriel  (ESA-SAI)		July 1996
	central wavelength added (WMT)                  Nov 1996
	Newheader as optional input (JAcosta)		Apr 1997
	Check for "old" aap type and corresponding
	 new computing of CWVL (CG)			Oct 97
	V6.5

(See /fill_aap.pro)


FILL_ERD

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       FILL_ERD

 PURPOSE:
	FILLS a temporary structure into the dynamical structure PHTERD  

 CATEGORY:
	PIA - I/O

 CALLING SEQUENCE:
       FILL_ERD, tmp [,newheader] [,REPLACE=replace]

 INPUT:
       tmp 	: ERD like temporary structure

 OPTIONAL INPUT:
	newheader:  New header to be change into the structure

 KEYWORD:
	REPLACE : IF set (different to 0) put structure into this PHTERD position

 RESTRICTIONS:
       tmp must be a valid phterd like temporary structure

 PROCEDURES USED: 
       Common Block(s) or @ procedure(s):
               phterd

 MODIFICATION HISTORY:
       Written by: C. Gabriel  (ESA-SAI)		July 1996
	newheader optional input added (CG)		May 1997
	V6.3
	Keyword FLAG added to the structure (CG)	Nov 1997
	V6.6

(See /fill_erd.pro)


FILL_SCP

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       FILL_SCP

 PURPOSE:
	FILLS a temporary structure into the dynamical structure PHTSCP  

 CATEGORY:
	PIA - I/O

 CALLING SEQUENCE:
       FILL_SCP, tmp, newheader, REPLACE=replace

 INPUT:
       tmp 	: SCP like temporary structure

 OPTIONAL INPUT:
	REPLACE : IF set (different to 0) put structure into this PHTSCP position

 RESTRICTIONS:
       tmp must be a valid phtscp like temporary structure

 PROCEDURES USED: 
       Common Block(s) or @ procedure(s):
               phtscp

 MODIFICATION HISTORY:
       Written by: C. Gabriel  (ESA-SAI)		July 1996
	Modified by: J. Acosta 				September 96
	V5.0 (Sept.96)

(See /fill_scp.pro)


FILL_SPD

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       FILL_SPD

 PURPOSE:
	FILLS a temporary structure into the dynamical structure PHTSPD  

 CATEGORY:
	PIA - I/O

 CALLING SEQUENCE:
       FILL_SPD, tmp [,newheader] [,REPLACE=replace]

 INPUT:
       tmp 	: SPD like temporary structure

 OPTIONAL INPUT:
	newheader:  New header to be change into the structure

 KEYWORD:
	REPLACE : IF set (different to 0) put structure into this PHTSPD position

 RESTRICTIONS:
       tmp must be a valid phtspd like temporary structure

 PROCEDURES USED: 
       Common Block(s) or @ procedure(s):
               phtspd

 MODIFICATION HISTORY:
       Written by: C. Gabriel  (ESA-SAI)		July 1996

(See /fill_spd.pro)


FILL_SRD

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       FILL_SRD

 PURPOSE:
	FILLS a temporary structure into the dynamical structure PHTSRD  

 CATEGORY:
	PIA - I/O

 CALLING SEQUENCE:
       FILL_SRD, tmp [,newheader] [,REPLACE=replace]

 INPUT:
       tmp 	: SRD like temporary structure

 OPTIONAL INPUT:
	newheader:  New header to be change into the structure

 KEYWORD:
	REPLACE : IF set (different to 0) put structure into this PHTSRD position

 RESTRICTIONS:
       tmp must be a valid phtsrd like temporary structure

 PROCEDURES USED: 
       Common Block(s) or @ procedure(s):
               phtsrd

 MODIFICATION HISTORY:
       Written by: C. Gabriel  (ESA-SAI)		July 1996
	Modified by: J. Acosta 				September 96
	V5.0 (Sept.96)

(See /fill_srd.pro)


FILT_NO

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	FILT_NO

 PURPOSE:
	Determine filter sequence number. This number is defined
	first by the sequence of the detector subsystem in the
	order: P1, P2, P3, C100, C200, and second by the sequence
	of rising nominal central wavelengths of the filters
	used. The numbers are assigned only for practically used
	filterpositions, e.g. backup filters etc. are left out.
	The filter name can be any string that has been used so
	far to unambiguous distinguish the filter. The 90micron
	backup filter is not recognised and will be taken as 
	90micron standard filter.
	The first character must be either 'P' or 'C', regardless
	of case!

 CATEGORY:
	PIA - processing

 CALLING SEQUENCE:
	FILT_NO(filter)

 INPUT:
	filter:		(string) 

KEYWORD PARAMETERS:	
	none

 OUTPUT:
	function:	(integer) filter number as described
			above

 COMMON BLOCKS:

 RESTRICTIONS:

 PROCEDURES USED:	
	EXTR_NUM

 EXAMPLE:

 MODIFICATION HISTORY:
	Written by:	Bernhard Schulz
	25/10/96	first version		B. Schulz
	19/01/99	bugfix in 2. num. part	B. Schulz

(See /filt_no.pro)


FIND_PARAM

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	FIND_PARAM

 PURPOSE:
	This is not an IDL routine as such, but contains the definition of the
	common block FIND_PARAM for inclusion into other routines.  By 
	defining the common block in one place, the problem of conflicting 
	definitions is avoided.

	This file is included into routines that need this common block with
	the single line (left justified)

				  @find_param

	This file stores the parameters for the deglitching routine:
	

 CATEGORY:
	PIA - common block

 MODIFICATION HISTORY:
	Written by:	Ingolf Heinrichson
	Oct 95 Version 3.5

(See /find_param.pro)


FIND_PARAM_INIT

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	FIND_PARAM_INIT

 PURPOSE:
	Initialise the find_param common block

 CATEGORY:
 	PIA - initialisation

 CALLING SEQUENCE:
	FIND_PARAM_INIT

 INPUTS:
	None

 OUTPUTS:
	None

 COMMON BLOCKS:
	find param

 PROCEDURES USED:
	None

 MODIFICATION HISTORY:
	Written by:	?
	Oct 95 Version 3.5

(See /find_param_init.pro)


FIT_FUNCTION

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	FIT_FUNCTION

 PURPOSE:
	Interface routine between measurement, signal drift parameters and 
	fitting routine

 CATEGORY:
	PIA - processing

 CALLING SEQUENCE:
	FIT_Function, xx, yy, yyerr, yyflag, drift_par, step=STEP, $ 
		RASTERSTEP = rasterstep

 INPUT:
	xx:	The independent variable
	yy:	The dependant variable
	yyerr:	Uncertainty array of yy
	yyflag:	Flag array corresponding to yy
	

 KEYWORD PARAMETERS:
	Step:	Chopper step (not set for non chopped measurements)
	WEIGHT: indicate which weighting system is used among the
		following possibilities:
			sigma 	=  1/sigma^2   (DEFAULT)
			none	= 1
			time    = exp((t-t_zero)/512.)
			signal	= 1/abs(signal)	
	          
	
 OUTPUT:
	drift_par:	A PIA_drift_par likely structure, containing e.g. the 
			fitted parameters, sigmas, etc
	
 COMMON BLOCKS:
	(none) 
		
 PROCEDURES USED:
	PIA lib:
		pia_curfit

 MODIFICATION HISTORY:
	Written by: C.Gabriel (ESA/VILSPA-SAI)	  August 1996
	New way to estimate the weights of points
	for the fit. A normalization based on stdev
	of the difference between consecutive signals
	J. Acosta				  January 1997
	Version 5.0 - Aug.96
	Bug in the flag treatment for chopped meas., 
	+ change call of get_nchoppsweep - JAcosta,  Aug 1997  
			

(See /fit_function.pro)


FIT_RAMPS

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	FIT_RAMPS

 PURPOSE:
	Fit a polynomial to the voltage ramps of a measurement returning 
	the slopes, their uncertainties and the fitted lines.

 CATEGORY:
	PIA - processing

 CALLING SEQUENCE:
    FIT_RAMPS, Xall, Yall, Ndeg, Rampend, Ylin, Yslop, Yslopr, $
	        Yflag, Ytime, Yresi, Ynros

 INPUTS:
	Yall	: Array containing values of read-outs from a measurement [V]
	Xall	: Array containing the independent variable [t]  (same size)
	Ndeg	: Polynomial degree

 OUTPUTS:
	Ylin	: Array containing the fitted lines
	Yslop	: Array of found slopes 
	Yslopr	: Array of uncertainties in slopes
	Yflag	: Array of flags (0:ok; 1:2 read-outs used; 2:bad)
	Ytime	: Slopes times   
	Yresi	: Array with effective reset intervals used
	Ynros	: Array with effective number of read-outs used

 RESTRICTIONS:
	Yall, Xall, Dr and Tint must have the same number of elements

 PROCEDURES USED:
	None

 MODIFICATION HISTORY:
	Written by:	Carlos Gabriel		
	Modified (last) by CG:	October 1996
	V5.x
	Flagging with 1 pseudo_ramps with less than !subd_ramp/2. 
	 to avoid problems with too small uncertainties
	Bug fixed: start time of pseudo-ramp was shifted one read-out (CG)
	V6.3 
	Bug fixed: double use of indices (CG)	September 1997
	V6.5
	Use of glitched flagged elements (CG)	November 1997
	V6.6
	Upgrade (larger efficiency) by Jose Acosta (IAC) using
	bitflag system				May 1999
	Data reduction info added (CG)		May 1999
	Mask bug by all points valid fixed (CG) June 1999	
	V7.4			

(See /fit_ramps.pro)


FIX_TKEY

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       FIX_TKEY

 PURPOSE:
	Fix the PHT instrument time key eliminating the effects caused by
	the virus (probably der_ERD) affecting the key every 2 seconds 

 CATEGORY:
	PIA - processing

 CALLING SEQUENCE:
       FIX_TKEY, Tkey, Tkeyfix

 INPUTS:
       Tkey 	: Original tkey

 OUTPUTS:
	Tkeyfix : Fixed tkey 

 PROCEDURES CALLED:
	ASTRO LIB: nint

 MODIFICATION HISTORY:
       Written by:	Carlos Gabriel
	Oct 95 Version 3.5

(See /fix_tkey.pro)


FLUX

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	FLUX

 PURPOSE:
	Converts input Power to Flux Density or Surface Brightness

 CATEGORY:
	PIA - processing

 CALLING SEQUENCE:
	FLUX, Power, Detector, Filter, Aperture, Type, Out

 INPUTS:
	Power    : Doubleprecision array of Power in W
	Detector : Subsystem - 'P', 'C1', 'C2', 'SS', 'SL'
	Filter   : Filter number            }  as
	Aperture : Aperture or pixel number } follows:
	      PHT-P : Filter number (1-14), aperture number (1-14)
	      PHT-C1: Filter number (1-8), pixel number (1-9)
	      PHT-C2: Filter number (9-14), pixel number (1-4)
	      PHT-SS: , Pixel number (1-64)
	      PHT-SL: , Pixel number (1-64)
	Type: Conversion type
	      0: Power -> Flux Density
	      1: Power -> Surface Brightness

 OUTPUTS:
	Out: Doubleprecision array, units depending on the conversion type

 COMMON BLOCKS:
	aperture_info
	pht_s
	phtapertures
	phtppsf

 RESTRICTIONS:
	For PHT-P, C, the aperture_info common block must be initialised first
	For PHT-S, the pht-s common block must be initialised first

 PROCEDURES USED:
	PIA LIB: flux_PC
	         flux_S
	         aperture_info_init
	         aperture_size_init

 MODIFICATION HISTORY:
	Written by:	Huw Morris
	Modified by:	C. Gabriel
	Oct 95 Version 3.5
	According to new flux_s routine (CG)		April 1996
	phtapertures not further use (CG)		February 1998
	V7.0

(See /flux.pro)


FLUX_PC

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	Flux_PC

 PURPOSE:
	Converts input Power into Flux Density or Surface Brightness for
	PHT-P and PHT-C

 CATEGORY:
	PIA - processing

 CALLING SEQUENCE:
	FLUX_PC, Power, Detector, Filter, Aperture, Type, Out

 INPUTS:
	Power    : Doubleprecision two-dim array of Power [pixel,npoints] (in W)
	Detector : 'P', 'C1', 'C2' 
	Filter   : Filter number
	Aperture : PHT-P aperture, or PHT-C pixel number
	Type: Conversion type
	      0: Power -> Flux Density
	      1: Power -> Surface Brightness

 OUTPUTS:
	Out: Doubleprecision 2dim-array (as Power), units depending on the 
	conversion type

 COMMON BLOCKS:
	phtppsf
	phtw2jy

 RESTRICTIONS:
     The aperture common block must be initialised first

 PROCEDURES USED:
     None

 Modification History:
	Written by:	Huw Morris
	Oct 95 Version 3.5
	Derivation changed, calibration numbers taken from phtw2jy common
	containing the C1 factors, telescope_area multiplication taken out
	for Jy -> MJy/sr (CG)					March 1996
	C100/C200 are not PSF corrected pixelwise now (CG)	January 1997
	V6.0
	Common aperture_info deleted, psf info by phtppsf,
	 filter and apert./pixel dependant omega used 
	 for surface brightness calculation (CG)		January 1998
	V7.0

(See /flux_pc.pro)


FLUX_S

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	Flux_S

 PURPOSE:
	Extracts the flux and surface brightness for PHT-S

 CATEGORY:
	PIA - processing

 CALLING SEQUENCE:
	FLUX_S, Power, Detector, Type, Out

 INPUTS:
	Power:    Doubleprecision array of input Power in W
	Detector: Either 'SS' or 'SL'
	Type:     Conversion type
	          0: Power -> Flux Density
	          1: Power -> Surface Brightness

 OUTPUTS:
	Out:      Doubleprecision array of either Flux Density F_nu in Jy
	          or F_lambda in W/m^2/micron

 COMMON BLOCKS:
	pht_s

 PROCEDURES_USED:
	pht_s_init

 MODIFICATION_HISTORY:
	Written by:	Huw Morris
	Oct 95 Version 3.5
	Changed for new derivation: use of W2jy_s and W2Mjy_s (CG)  March 1996
	Bug for rasters fixed, input pixel taken out  (CG)	    April 1996	

(See /flux_s.pro)


FPGC_MANAGER

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	FPGC_MANAGER

 PURPOSE:
	Menu for FPGC file selection and analysis.

 CATEGORY:
	PIA - graphics

 CALLING SEQUENCE:
	FPGC_MANAGER

 INPUTS:
	none
	
 OUTPUTS:
	none

 PROCEDURES CALLED:
	PIA LIB: anal_fpgc
	         pia_disp_print_table
	
 MODIFICATION HISTORY:
	Written by:	Ingolf Heinrichsen
	Modified by:	C. Gabriel
	Oct 95 Version 3.5

(See /fpgc_manager.pro)


FPG_CROSS

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
     FPG_CROSS

 PURPOSE:
       Analyse Focal Plane Geometry Cross Scans

 CATEGORY:
	PIA - processing

 CALLING SEQUENCE:
	FPG_CROSS, Iscpfile, Fpgcfile, Centre

 INPUTS:
	Iscpfile: name of ISCP product file, containing cross scan data
	Fpgcfile: name of Focal Plane Geometry Calibration File, related
				 to cross scan


 KEYWORD PARAMETERS:
	SCAN		Defines whether to use Y or Z coordinate from FPGC file
				'Y': use Y coordinate
				'Z': use Z coordinate
				if not specified default is use Y coordinate

	INTER		Decides, whether s/w shall run in:
						'Y' = interactive mode
						'N' = automatic mode
						defualt is 'N'

	PIXEL 	decide which PHT-S pixel shall be analysed
						default=1

	ERROR		Returns an error status:
						0 = no error
						1 = error: output is not valid

 OUTPUTS:
	Centre: coordinate of scan centre, in FPGC coordinates

 COMMON BLOCKS:
	phtscp

 PROCEDURES CALLED:
	PIA LIB: read_fpgc	
	         read_ispd
	         pia_xplot
	         multi_fit

 MODIFICATION HISTORY:
       Written by:	Ingolf Heinrichsen
	Modified by:	C. Gabriel
	Oct 95 Version 3.5
	Call to pia_multi_fit using weights and flags (CG)	October 1995

(See /fpg_cross.pro)


FXBINTABLE

[Previous Routine] [Next Routine] [List of Routines]
 Project     : SOHO - CDS

 Name        : 
	FXBINTABLE
 Purpose     : 
	Common block FXBINTABLE used by "FXB" routines.
 Explanation : 
	This is not an IDL routine as such, but contains the definition of the
	common block FXBINTABLE for inclusion into other routines.  By defining
	the common block in one place, the problem of conflicting definitions
	is avoided.

	This file is included into routines that need this common block with
	the single line (left justified)

				  @fxbintable

	FXBINTABLE contains the following arrays:

		LUN	= An array of logical unit numbers of currently (or
			  previously) opened binary table files.
		STATE	= Array containing the state of the FITS files
			  associated with the logical unit numbers, where
			  0=closed, 1=open for read, and 2=open for write.
		HEAD	= FITS binary table headers.
		MHEADER	= Array containing the positions of the first data byte
			  of the header for each file referenced by array LUN.
		NHEADER	= Array containing the positions of the first data byte
			  after the header for each file referenced by array
			  LUN.
		NAXIS1	= Values of NAXIS1 from the binary table headers.
		NAXIS2	= Values of NAXIS2 from the binary table headers.
		TFIELDS	= Values of TFIELDS from the binary table headers.
		HEAP	= The start of the first byte of the heap area
			  for variable length arrays.
		DHEAP	= The start of the first byte of the next variable
			  length array, if writing.
		BYTOFF	= Byte offset from the beginning of the row for each
			  column in the binary table headers.
		TTYPE	= Values of TTYPE for each column in the binary table
			  headers.
		FORMAT	= Character code formats of the various columns.
		IDLTYPE	= IDL type code for each column in the binary table
			  headers.
		N_ELEM	= Number of elements for each column in the binary
			  table headers.
		TSCAL	= Scale factors for the individual columns.
		TZERO	= Zero offsets for the individual columns.
		MAXVAL	= For variable length arrays, contains the maximum
			  number of elements for each column in the binary
			  table headers.
		N_DIMS	= Number of dimensions, and array of dimensions for
			  each column of type string in the binary table
			  headers.
 Category    : 
	Data Handling, I/O, FITS, Generic.
 Prev. Hist. : 
	William Thompson, Feb 1992.
 Written     : 
	William Thompson, GSFC, February 1992.
 Modified    : 
	Version 1, William Thompson, GSFC, 12 April 1993.
		Incorporated into CDS library.
	Version 2, William Thompson, GSFC, 21 July 1993.
		Added DHEAP variable to fix bug with variable length arrays.
 Version     : 
	Version 2, 21 July 1993.

(See /fxbintable.pro)


GENCHO

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	GENCHO

 PURPOSE:
	Definition of the common block GENCHO for inclusion into other routines.  By defining
	The common block GENCHO contains different flags for driving automatic
	processing.

 CATEGORY:
       PIA - common block

 CALLING SEQUENCE:
	@gencho

 COMMON BLOCK PARAMETERS:
	gen_(several parameters driving the processing)

 MODIFICATION HISTORY:
	Wrtten by: Carlos GABRIEL(ESA/VILSPA-SAI) 	December 1995
  OBSOLETE 
  OBSOLETE   Superseded by gen_choices
  OBSOLETE 

(See /gencho.pro)


GEN_AAP

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       GEN_AAP

 PURPOSE:
       Fills in DECP and RAP fields of PHTIAAP structure which contains the 
	central RA and DEC position for every point in the AAP, including chopper 
	deflections and detector pixel offsets.  This makes the data more 
	transparent and mapping easier.

 CATEGORY:
       PIA - processing

 CALLING SEQUENCE:
       GEN_AAP, phtiaap

 INPUTS:
       PHTIAAP		The AAP structure

 KEYWORD PARAMETERS:
	(none)

 OUTPUTS:
       PHTIAAP		The AAP structure with correct DECP and RAP

 COMMON BLOCKS:
       (none)

 PROCEDURES USED:
       PIA Procedure(s):	 

       Astronomical Library:	FXPAR

 FUNCTIONS USED:	pixel_det (function) 

 MODIFICATION HISTORY:
       Written by:             Min Hur, IPAC/Caltech       	Jan 2000
	Bug for staring case fixed (CG)				Mar 2000
	V8.2

(See /gen_aap.pro)


GEN_CHOICES

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	GEN_CHOICES

 PURPOSE:
	Definition of the common GEN_CHOICES for inclusion into other routines.  By defining
	The common block GEN_CHOICES contains values for driving automatic
	processing.

 CATEGORY:
       PIA - common block

 CALLING SEQUENCE:
	@gen_choices

 COMMON BLOCK PARAMETERS:
	gen_(several structures / parameters driving the processing)

 MODIFICATION HISTORY:
	Written by: Carlos GABRIEL(ESA/VILSPA-SAI) 	April 1997
	Extension: gen_process	(CG+JA)			May 1997
	V6.3

(See /gen_choices.pro)


GEN_CHOICES_INIT

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       GEN_CHOICES_INIT

 PURPOSE:
       Initializes the COMMON block GEN_CHOICE used for automatic /
	batch processing.

 CATEGORY:
       PIA - initialization

 CALLING SEQUENCE:
       @gen_choices_init

 MODIFICATION HISTORY:
       Written by: C.Gabriel (ESA/VILSPA - SAI)		April 1997
	V6.2
	Extensions: reset interval & vignetting corrections + rpid->0b +
		gen_process ->drft,splitrp  (CG+JA)		May 1997
	V6.3
	Resp choices now for single and double options (CG)	July 1997
	V6.4
	Pair deglitching (ERD), chopper frequency dependance and
	 selection for correction menues added (CG)		January 1998
	V7.0
	Siglin added (CG)					January 1999
	V7.3
	Pattern added (CG)					March 1999
	Siglin on SCP added (CG)				June 1999
	V7.4
       Change default ERD deglitch to 2-Thr.    (CG)           July 1999
       V8.0
	PHT-S chopped dynamic calibration added (CG)		September 1999
	V8.1
	PHT-S pointing correction added (CG)			December 1999
	V8.2

(See /gen_choices_init.pro)


GEN_PAP

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       GEN_PAP

 PURPOSE:
       Creates a PHTIAAP 2000 structure using the PHTIAAP of last millenium.  
	Contains empty arrays for the 
	central RA and DEC position for every point in the AAP, including chopper 
	deflections and detector pixel offsets.  This makes the data more 
	transparent and mapping easier.

 CATEGORY:
       PIA - processing

 CALLING SEQUENCE:
       GEN_PAP, phtiaap, phtipap

 INPUTS:
       PHTIAAP		The old AAP structure

 KEYWORD PARAMETERS:
	(none)

 OUTPUTS:
       PHTIPAP		The resulting PHTIPAP = AAP2000

 COMMON BLOCKS:
       (none)

 PROCEDURES USED:
       PIA Procedure(s):	 

       Astronomical Library:	FXPAR

 FUNCTIONS USED:	pixel_det (function) 

 MODIFICATION HISTORY:
       Written by:             Min Hur, IPAC/Caltech       	Jan 2000

(See /gen_pap.pro)


GETSAVE

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	GETSAVE

 PURPOSE:
	Initialises the phtaap common block with values in the tmparr
	structure.

 CATEGORY:
	PIA - initialisation

 CALLING SEQUENCE:
	GETSAVE

 INPUTS:
	None

 OUTPUTS:
	None

 COMMON BLOCKS:
	phtaap

 PROCEDURES USED:
	PIA LIB: pia_mktrans
	         pia_xy2rd

 MODIFICATION HISTORY:
	Written by:	?
	Oct 95 Version 3.5

(See /getsave.pro)


GET_ACCVOLT

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       GET_ACCVOLT

 PURPOSE:
       Get a flag array corresponding to the read-outs which are discarded
       due to saturation 

 CATEGORY:
       PIA - processing

 CALLING SEQUENCE:
       GET_ACCVOLT, Tmpdata, volt_disc

 INPUTS:
       Tmpdata: A PHT-ERD temporary structure

 OUTPUTS:
       volt_disc: A flag array (same dimensions as phterd.conp) with flag=1
                for all discarded signals

 KEYWORDS:
       ENCODE_FLAG: when select tmpdata.flag is changed accordingly to flag 
  	             encodding

 COMMON BLOCKS:
       phtacc
       phtselndr

 PROCEDURES USED:
       None

 MODIFICATION HISTORY:
       Written by:     Jose Acosta 				      May 1999
       V7.4

(See /get_accvolt.pro)


GET_BOUNDARIES

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       GET_BOUNDARIES

 PURPOSE:
       Check an idb array for the boundaries of the ANA and STS part

 CATEGORY:
	PIA - processing

 CALLING SEQUENCE:
       GET_BOUNDARIES, Idb, Idb_f_bounds

 INPUTS:
       Idb         :database array

 OUTPUTS:
       Idb_f_bound:  0: begin status  1: end status
                     2: begin analog  3: end analog
 
 PROCEDURE:
       Idb has to be sorted, first coming all the status
       and then the analog data.
       get_boundaries searches only for the first ANA entry        

 PROCEDURES USED:
       None

 MODIFICATION HISTORY:
       Written by:	Andreas Karch
	Oct 95 Version 3.5

(See /get_boundaries.pro)


GET_CC.PRO

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	GET_CC.PRO

 PURPOSE:
	Provide colour correction factor depending on filter and spectral
	type for a black-body spectrum of a given temperature or a
	power-law spectrum. Linear interpolation of CC table is
	performed for a given temperature. 

 CATEGORY:
	PIA - I/O

 CALLING SEQUENCE:
	GET_CC, filter, type, parameter, cc_val

 INPUTS:
       filter :        string containing filter name as defined in
                       COMMON block phtfilter
       type   :        'bb'     for Black-body
                       'power'  for Power-law
                       'mbbnu1' for modified BB with emissivity
                                proportinal nu^1
                       'mbbnu2' for modified BB with emissivity
                                proportinal nu^2
       parameter:      Temperature; if type='bb', 'mbbnu1' or 'mbbnu2'
                       Power-law index; if type='power' 

 OUTPUTS:
      cc_val    :        colour correction factor

 KEYWORD PARAMETERS:
	ERROR : 	returns an error condition:
			0 = no error
			1 = could not successfully read the necessary table
	ASCII :         if set read ASCII file, otherwise read FITS file

 PROCEDURES USED:
       Internal:
               read_ccbb

 MODIFICATION HISTORY:
	Written by: 	I. Heinrichsen, MPIK/Heidelberg, Mai 1997
	                V6.3
                       IH, changed format of cc_bb.txt
                           added modified BBs
	                V6.4
                       IH, read FITS files added
                       V6.6
	Different names for CALG (without _ and numbers) added (CG)	Apr 98
 V7.1
	Using also -1. as invalid temperature (CG)			Dec. 99
	V8.2

(See /get_cc.pro)


GET_CHOPSTEPS

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	GET_CHOPSTEPS

 PURPOSE:
	Get a step array corresponding to the different chopper positions 

 CATEGORY:
	PIA - processing

 CALLING SEQUENCE:
       GET_CHOPSTEPS, Cpos, Step

 INPUTS:
       Cpos: An array containing different chopper positions

 OUTPUTS:
       Step:  An array (same dimensions as cpos) with position steps

 PROCEDURES USED:
	None

 MODIFICATION HISTORY:
       Written by:	Carlos Gabriel
	Oct 95 Version 3.5

(See /get_chopsteps.pro)


GET_CONVWH

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	GET_CONVWH

 PURPOSE:
	Get the converted wheels positions, chopper mode and amplitude
	corresponding to tmpdata from the Compact Status structure. 

 CATEGORY
	PIA - processing

 CALLING SEQUENCE:
       GET_CONVWH, Measname, Wheels, Chmod, Champ

 INPUTS:
       Measname: A PHT measurement name (admn)

 OUTPUTS:
       Wheels: A 3 string array containing the converted wheel positions 
	Chmod:	The chopper mode
	Champ:	The chopper amplitude

 COMMON BLOCKS:
	phtcs

 RESTRICTIONS:
       Measname must correspond to an ISOPHOT measurement. The corresponding
	Compact Status informations must be contained whether in a FITS file
	or in the phtcs dynamical structure
 
 PROCEDURES USED:
	PIA LIB: conv_cs
	         read_cs

 MODIFICATION HISTORY:
       Written by:	Carlos Gabriel - ESA-SAI
	Oct 95 Version 3.5
	Version 5.0

(See /get_convwh.pro)


GET_COORDINATES

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       GET_COORDINATES

 PURPOSE:
       Read a PHT IRPH file filling the coordinates data into the SPD 
       temporary structure given as input
 
 CATEGORY:
       PIA - I/O

 CALLING SEQUENCE:
       get_coordinates, admn, rpid, ra, dec, roll

 INPUT:
       admn : Identification of a valid measurement (12 character string).
	rpid :  Raster point Id for the same measurement (BYTARR[2,npts])

 OUTPUT:
	ra :  Right Ascension (FLTARR[npts])
	dec:  Declination (FLTARR[npts])
	roll: Roll Angle (FLTARR[npts])
	

 PROCEDURES USED:
       Common Block(s) or @ procedure(s):
               phtcs
       PIA Procedure(s):
               read_irph
               read_cs

 MODIFICATION HISTORY:
       Written by: Jose Acosta (ISO-Soc/VILSPA)     		July 1998
       V7.x
	Some text added (CG)					March 1999
	V7.4
	Reading internal PIA IRPH files added (for simulations)	September 1999
	V8.1

(See /get_coordinates.pro)


GET_DARKCSTR

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       GET_DARKCSTR

 PURPOSE:
       Returns the dark current structure corresponding to detector
 
 CATEGORY:
	PIA - processing
       
 CALLING SEQUENCE:
       GET_DARKCSTR, Det, Darkcstr

 INPUTS:
       Det: Detector name. One of: P1, P2, P3, C1, C2, SL

 OUTPUTS:
       Darkcstr: the corresponding dark current structure

 PROCEDURES USED:
	None

 MODIFICATION HISTORY:
	Written by: Carlos Gabriel
	Oct 95 Version 3.5
       Check if the calsave file exists, if not then  
	returns a dummy structure (JAcosta)			October 1997

(See /get_darkcstr.pro)


GET_DARKCUR

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       GET_DARKCUR

 PURPOSE:
       Returns the dark current array corresponding to the detector.
 
 CATEGORY:
	PIA - processing
       
 CALLING SEQUENCE:
       GET_DARKCUR, Det, Darkcurr

 INPUTS:
       Det: Detector name. One of -- P1, P2, P3, C1, C2, SL

 OUTPUTS:
       Darkcurr: the corresponding dark current array

 COMMON BLOCKS:
       phtdarkcur

 PROCEDURE:
       Use FXPAR to extract the keyword info.

 PROCEDURES USED:
	ASTRO LIB: fxpar

 MODIFICATION HISTORY:
	Written by:	Carlos Gabriel
	Oct 95 Version 3.5

(See /get_darkcur.pro)


GET_FCSPRE_STR

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       GET_FCSPRE_STR

 PURPOSE:
       Returns the FCS Pre-reduced Signal Table corresponding to the detector
 
 CATEGORY:
	PIA - I/O
       
 CALLING SEQUENCE:
       GET_FCSPRE_STR, Det, Fcsprestr

 INPUTS:
       Det: Detector name. One of -- P1, P2, P3, C1, C2

 OUTPUTS:
       Fcsprestr: the corresponding fcs Pre-Reduced Signal Table

 PROCEDURES USED:
	None

 MODIFICATION HISTORY:
	Written by:	Carlos Gabriel		October 1995

(See /get_fcspre_str.pro)


GET_FCSPSTR

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       GET_FCSPSTR

 PURPOSE:
       Returns the FCS power structure corresponding to the detector
 
 CATEGORY:
	PIA - I/O
       
 CALLING SEQUENCE:
       GET_FCSPSTR, Det, Fcspstr

 INPUTS:
       Det: Detector name. One of -- P1, P2, P3, C1, C2

 OUTPUTS:
       Fcspstr: the corresponding fcs power structure

 PROCEDURES USED:
	None

 MODIFICATION HISTORY:
	Written by:	Carlos Gabriel
	Oct 95 Version 3.5
	Typ changed	CG	October 1995

(See /get_fcspstr.pro)


GET_HEADLINE

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	GET_HEADLINE

 PURPOSE:
	Define a headline out of a PIA map parameter structure  

 CATEGORY:
	PIA - I/O

 CALLING SEQUENCE:
	res = GET_HEADLINE(par, n, mm=mm, title=title)

 INPUTS:
	par	: PIA map parameter structure
	n	: type of map (0:surf.bright., 1:unc., 2:exposure, -1:unknown)

 OUTPUT KEYWORDS:
	MM	: map method string (eg. "Distance Weighting")
	TITLE	: Default title according to type and datatype of map


 MODIFICATION HISTORY:
	Written by:	Carlos Gabriel (ESA/VILSPA-SAI)		January 1999
	V7.4

(See /get_headline.pro)


GET_INBPOWER

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       GET_INBPOWER

 PURPOSE:
       Returns the In-band power corresponding to a Source on a given filter,
	as quoted in the calibration file

 CATEGORY:
	PIA - I/O

 CALLING SEQUENCE:
	GET_INBPOW, FILENAME, SOURCE_ID, FILTER_ID, INBPOWER

 INPUT:
	filename:	The file to be searched
	source_id:	Name of the source
	filter_id:	Official filter identifier       

 OUTPUT:
	inbpower:	The in-band power expected

 PROCEDURES USED:

 MODIFICATION HISTORY:
       Written by: Carlos GABRIEL (ESA-SAI)	November 1995

(See /get_inbpower.pro)


GET_NCHOPPSWEEP

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       GET_NCHOPPSWEEP
 PURPOSE:
	Given a sequence of chopper positions will produce an array containing
 	the index where any chopper sweep occurs.  

 CATEGORY:
       PIA - processing
                
 CALLING SEQUENCE:
       GET_NCHOPPSWEEP, step, nchopp, ind_sweep, chopstep

 INPUT PARAMETERS: 
	STEP:		
 OUTPUT: 
    	SWEEP_STEP: 	jump of chopper units
    	CHOPSTEP:sequential index of step: 1111-2222-1111 ...--> 1111-2222-3333
 RESTRICTIONS:

 PROCEDURES USED:
       Common Block(s) or @ procedure(s):

       PIA Procedure(s):
               
       Astronomical Library:

 MODIFICATION HISTORY:
       Written by: J. Acosta				July 1996
       V5.x
	Change one output argument, chopstep is now 
	sequential change of steps.  JAcosta		Aug. 1997
       Bug corrected using nr_ref    JAcosta		Nov. 1997
	Bug for > 32760 chopper plateaus fixed (CG)	Jun. 1998
	V7.2	

(See /get_nchoppsweep.pro)


GET_OMEGA

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	GET_OMEGA

 PURPOSE:
	This function returns omega values und uncertainties from phtomega

 CALLING SEQUENCE:
	res = GET_OMEGA(detector, aperture/pixel, filter)

 INPUTS:
	detector:	one element out of 'P*', 'C1', 'C2'
	aperture/pixel:	aperture(0-13) for 'P', pixel for C100/C200 
			(can be array of numbers)
	filter:		0-13 for P, 0-7 for C100, 0-4 for C200 
			(can be array of numbers)

 OUTPUTS:
	Returns     res = FLTARR(aper/pixel, filter, 2)  for chosen
			  aper/pixel(s) and filter(s) with

			res(*,*,0) = values
			res(*,*,1) = uncertainties

 RESTRICTIONS:

 COMMON BLOCKS:
       phtomega

 PROCEDURES USED:

 MODIFICATION HISTORY:
	Written by: Carlos GABRIEL (ESA/VILSPA-SAI)		Jan 98 
	V7.0

(See /get_omega.pro)


GET_PHT_HK

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	GET_PHT_HK

 PURPOSE:
	This routine needs an specific measurement-name as an input. It
       then loads the corresponding PSTA and GEHK fits files and
       extracts the specific data for this measurement.
       All values, including the time, are converted to strings or to
       physical values. The converted time is in seconds with t=0s
       at the start of the PSTA .
       Output is stored in the phthk common block.

 CATEGORY:
	PIA - I/O

 CALLING SEQUENCE:
       GET_PHT_HK, Meas_name, Phtcs_redu

 INPUTS:
       Meas_name : Name of measurement

 KEYWORDS:
	FULL_TDT: IF set, full TDT info is extracted rather than the one
		corresponding to the measurement
 OUTPUTS:
       Phtcs_redu: Structure with the reduced and converted ext. hk 

 COMMON BLOCKS:
	phtcs
	phthk
 
 PROCEDURE:
       Use the uk-time for extracting, then convert to seconds.
       Use conv_hk and conv_cs to convert the rawvalues. 

 PROCEDURES USED:
       PIA LIB:   read_idb_def
                  read_cs
	           read_phthk
                  conv_hk
                  conv_cs
	ASTRO LIB: fxbclose
	           fxbopen
	           sxpar	

 MODIFICATION HISTORY:
       Written by:	Andreas Karch
	Modified by:	C. Gabriel
	Oct 95 Version 3.5
	Bug with CS name (fxbopen) fixed  (CG)	Nov 95

(See /get_pht_hk.pro)


GET_RAMPEND

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	GET_RAMPEND

 PURPOSE:
	determines the limits of all ramps at ERD level, using DR and 
	taking into account possible telemetry drops. It also works
       when ramp subdivision is selected. 

 CATEGORY:
	PIA - processing

 CALLING SEQUENCE:
    GET_RAMPEND, Xall, Dr, Tint, Rampflag, Rampend, Dimsrd, SUB_RAMP =sub_ramp 

 INPUTS:
	Xall	: Array containing the independent variable [t]  (same size)
	Ndeg	: Polynomial degree
	Dr	: Read-out status (0 = NDR, 1 = DR) 
	Tint	: On chip integration time applied in the measurement

 OUTPUTS:
	Rampflag: Array containing a flag specifying the actual end of a 
		  ramp.
	Rampend : Array containing the index where ramps end.
	Dimsrd	: Dimension of SRD
	

 KEYWORD INPUT:
	SUB_RAMP: Specifies the number of sub-ramps
	DATRED:	  Data reduction factor

 RESTRICTIONS:
	Xall, Dr and Tint must have the same number of elements

 PROCEDURES USED:
	None

 MODIFICATION HISTORY:
	Written by:	Jose Acosta 				May 1999
	Data reduction keyword added (CG)			May 1999	
	Rampends in the right sequence if time drop 
	 and tolerance larger cause of chopper pl. (CG)		May 1999
	V7.4
	Check for avoiding rampends twice (CG)			July 1999
	V8.0

(See /get_rampend.pro)


GET_RAMPSPLIT

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	GET_RAMPSPLIT

 PURPOSE:
	Given an index containing the end of ramps (ERD level) provides a 
       new index containing the end of subramps after ramp splitting, using 
	an specified number of	valid readouts.

 CATEGORY:
	PIA - processing

 CALLING SEQUENCE:
	newrampend = get_rampsplit(rampend, NDR_subramp)

 INPUT PARAMETERS:
	rampend		: Index containing the end of complete ramps
	NDR_subramp	: Number of readouts for each subramp

 OUTPUT PARAMETERS:
	newrampend	: Index containing the end of subramps

 KEYWORD INPUT
	
 
 RESTRICTIONS:


 METHOD:


 COMMON BLOCKS:

 MODIFICATION HISTORY:
	Written by: J.Acosta (IAC)			May 1999
	V7.4

(See /get_rampsplit.pro)


GET_RASTERSTEPS

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	GET_RASTERSTEPS

 PURPOSE:
	Get a step array corresponding to the different raster positions 

 CATEGORY:
	PIA - processing

 CALLING SEQUENCE:
       GET_RASTERSTEPS, Rpid, Step[, TIME=time, flag]

 INPUTS:
       Rpid: A Raster Point ID array (BYTEARR(2,*))  

 OUTPUTS:
       Step: An array (same dimensions as RPID(0,*) with position steps

 KEYWORD INPUT:
	Time: A time array (same dimensions as RPID(0,*)) necessary for
		calculating the flag
	in_rast: Set if in_rast_pos should be calculated

 OPTIONAL OUTPUT: 
	Flag: An array (same dim as time) flagging with 2 all the elements
		of every raster point within the first 2 seconds after begin
	in_rast_pos: An array of positions within the raster point.

 PROCEDURES USED:
	None

 MODIFICATION HISTORY:
       Written by:	Carlos Gabriel
	Modified by CG (last: September 1996)
	Version 5.0
	In_rast_pos as output added (CG)		October 1997
	V6.5
	Bug by introducing bitflag system fixed (CG)	August 1999
	V8.0+

(See /get_rastersteps.pro)


GET_RESPONS

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	GET_RESPONS

 PURPOSE:
	Responsivity calculation.

 CATEGORY:
	PIA -  processing

 CALLING SEQUENCE:
	GET_respons, tmpdata, header

 INPUTS:
	tmpdata
		A temporary SCP structure
	header
		The corresponding header
	
 KEYWORD PARAMETERS:
	GROUP
		The group leader of the widget hirarchy
	NO_WIDGET
		To work without widget use - [=1: avg FCS1, =2: medians FCS1]
	
 OUTPUTS:
	header
		Modified header
	
 KEYWORD OUTPUT:
	out_of_limits	If out_of_limits check positive, is set to 1
	err_resp	If no responsivity can be calculated, return with 1	
	
 SIDE EFFECTS:
	Variables in the common block for actual responsivities are changed
	
 RESTRICTIONS:
	tmpdata must be a temporary PIA SCP structure, corresponding to an
	FCS measurement

 METHOD:
	Use of an FCS measurement and the corresponding calibration tables
	for the responsivity determination	

 COMMON BLOCKS:
	respon_cmn	local common
	phtcs		compact status dynamical structure
	phtresdef	default responsivities common
	phtresact	actual responsivities common
	phtfcs		FCS calibration tables
	phtillum	FCS illumination matrices common
	phtcap		capacitances common
	phtoptpow	FCS optical power range
	phtacc		actual selection criteria
	
 PROCEDURES USED:
	PIA Procedure(s):
		conv_subs
		cp_disc
		phtcap_init
		read_cs
		read_fcsill
		read_fcspow
		read_resp
	Internal:
		pia_respons_event
	Astrolib:
		fxaddpar

 MODIFICATION HISTORY:
	Written by:	Jose Acosta (ESA/VILSPA)		June 1998
	V7.2
	ERR_RESP keyword added (CG)				November 1998
	V7.3
	Filter to Filter for P added (CG)			July 1999
	V7.9

(See /get_respons.pro)


GET_RESPSTR

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       GET_RESPSTR

 PURPOSE:
       Returns the responsivity structure corresponding to detector from the
       save file.
 
 CATEGORY:
	PIA - I/O
       
 CALLING SEQUENCE:
       GET_RESPSTR, Det, Respstr

 INPUTS:
       Det: Detector name. One of -- P1, P2, P3, C1, C2, SL

 OUTPUTS:
       Respstr: The corresponding responsivity structure

 PROCEDURES USED:
	None

 MODIFICATION HISTORY:
	Written by:	Carlos Gabriel
	Modified by:	Wai-Ming Tai
	Oct 95 Version 3.5

(See /get_respstr.pro)


GET_RODISC

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	GET_RODISC

 PURPOSE:
	Get a flag array corresponding to the read-outs which are discarded
	according to the actual variables in PHTACC 

 CATEGORY:
	PIA - processing

 CALLING SEQUENCE:
       GET_RODISC, Tmpdata, Ro_disc

 INPUTS:
       Tmpdata: A PHT-ERD temporary structure

 OUTPUTS:
       Ro_disc: A flag array (same dimensions as phterd.conp) with flag=1
		 for all discarded signals

 KEYWORDS:
	ENCODE_FLAG: select if tmpdata.flag is changed with the flag encoded

 COMMON BLOCKS:
	phtacc
	phtselndr

 PROCEDURES USED:
	None

 MODIFICATION HISTORY:
	Written by:	Carlos Gabriel
	Oct 95 Version 3.5
	Last ramp bug fixed (CG)		December 1995
	allowing for gen criteria and 1st NDR deselected (CG)	May 1996
	Changed according to bitflag system (CG)		May 1999
	V7.4

(See /get_rodisc.pro)


GET_RPCHOPSTEP

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	GET_RPCHOPSTEP

 PURPOSE:
	Get the indices of raster position / chopper plateau combination.

 CATEGORY:
	PIA - algorithms

 CALLING SEQUENCE:
	GET_RPCHOPstep, rastersteps, step, rpchopstep, in_plat_pos 

 INPUT:
	rastersteps:	array with raster indices
	step:		array with chopper step position

 OUTPUT:
	rpchopstep:	array (same length as input) with consecutive
			raster-chopper combination.
	in_plat_pos:	array (same length as input) with position within
			raster-chopper plateau
	
 RESTRICTIONS:
	
 COMMON BLOCKS:
		
 PROCEDURES USED:
	PIA LIB:
		get_nchoppsweep

       INTERNAL:
		

 MODIFICATION HISTORY:
	Written by: J. Acosta (IAC-La Laguna) +cg	December 1996
	in_plat_pos now normal output (CG)		January 1997
	Avoiding INDGEN in long loops +
	 loops long initialized (CG)			September 1997
	V6.5
	Bug by raster jump fixed (CG)			August 1999
	V8.0+
			

(See /get_rpchopstep.pro)


GET_RPCHOP_SRD

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	GET_RPCHOP_SRD

 PURPOSE:
	Get the indexes of a given raster position and chopper plateau.
	If keyword chopped is set then gives the next chopper plateau

 CATEGORY:
	PIA - algorithms

 CALLING SEQUENCE:
	GET_RPCHOP_SRD, raststeps, step, irast, istep, indrstchopp 
	   [, indrstchopp2] [,/CHOPPED]   

 INPUT:
	tmpdata:	A phtsrd like temporary structure
	pixel:		The pixel number of the data to be used

 KEYWORD PARAMETERS:
	CHOPPED: If two contiguous chopper plateau are required
	
 RESTRICTIONS:
	TMPDATA must be a valid PHTSRD temporary structure
	
 COMMON BLOCKS:
		
 PROCEDURES USED:
	PIA LIB:
		get_nchoppsweep

       INTERNAL:
		

 MODIFICATION HISTORY:
	Written by: J. Acosta (IAC-La Laguna)		September 1996
	Bug corrected (J.Acosta)  			October 1996
	Version 5.x - Oct.96
			

(See /get_rpchop_srd.pro)


GET_SCPDISC

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	GET_SCPDISC

 PURPOSE:
	Get a flag array corresponding to the chopper plateaus which are 
	discarded according to the actual variables in the common block
	phtacc.

 CATEGORY:
	PIA - processing

 CALLING SEQUENCE:
       GET_SCPDISC, Tmpdata, Scp-disc

 INPUTS:
       Tmpdata: A PHT-SCP temporary structure

 OUTPUTS:
       Scp_disc: A flag array (same dimensions as phtscp.aver) with flag=1
	          for all discarded signals

 COMMON BLOCKS:
 	phtacc

 KEYWORD INPUT:
	Encode_flag:	Put info on bitflag system

 PROCEDURES USED:
	None

 MODIFICATION HISTORY:
       Written by:	Carlos Gabriel (ESA/ESTEC-SAI)
	Oct 95 Version 3.5
	Bad flagged if tmpdata.FLAG > 1 (CG)		January 1996 
	Bug for individual selection fixed (CG)		September 1997
	V6.5
	Bitflag system change (CG)			May 1999
	V7.4

(See /get_scpdisc.pro)


GET_SIGDISC

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	GET_SIGDISC

 PURPOSE:
	Get a flag array corresponding to the signals which are discarded
	according to the actual variables in the common block phtacc. 

 CATEGORY:
	PIA - processing

 CALLING SEQUENCE:
       GET_SIGDISC, Tmpdata, Sig_disc [,Raststeps, Rpchopstep] 

 INPUTS:
       Tmpdata: A PHT-SRD temporary structure

 OUTPUTS:
       Sig_disc:   A flag array (same dimensions as phtsrd.slop) with flag=1
		    for all discarded signals
	Raststeps:  An array with consecutive raster positions (as output from
		    get_rastersteps)
	Rpchopstep: An array with consecutive raster-chopper combinations (as
		    output of get_rpchopstep)

 KEYWORDS:
	ENCODE_FLAG: select if tmpdata.flag is changed with the flag encoded

 COMMON BLOCKS:
	phtacc
	rp_limits

 PROCEDURES USED:
	None

 MODIFICATION HISTORY:
       Written by:	Carlos Gabriel
	Oct 95 Version 3.5
	Bug with last point fixed (CG)		December 1995
	Long variables for loops (CG)		January 1996
	Extension for discarding signals per raster point,
	output extension (CG)			September 1997
	V6.5  
	Extension for discarding ch.pl. portions (CG)	January 1998
	V7.0
	Update (JA+CG)					May 1999
	V7.4

(See /get_sigdisc.pro)


GET_SPDDISC

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	GET_SPDDISC

 PURPOSE:
	Get a flag array corresponding to the chopper plateaux which are 
	discarded according to the actual variables in the common block
	phtacc. 

 CATEGORY:
	PIA - processing

 CALLING SEQUENCE:
       GET_SPDDISC, Tmpdata, Spd_disc

 INPUTS:
       Tmpdata: A PHT-SPD or PHT-AAP temporary structure

 OUTPUTS:
       Spd_disc: A flag array (same dimensions as tmpdata.flag) with flag=1
		  for all discarded signals

 COMMON BLOCKS:
	phtacc

 KEYWORD INPUT:
	Encode_flag:	Put info on bitflag system

 PROCEDURES USED:
	None

 MODIFICATION HISTORY:
       Written by:	Carlos Gabriel (ESA/ESTEC-SAI)
	Oct 95 Version 3.5
	Bad flagged if tmpdata.FLAG > 1 (CG)		January 1996 
	Bug for individual selection fixed (CG)		September 1997
	V6.5
	Extended for being used by AAP also (CG)	November 1997
	V6.6
	Bitflag system change (CG)			May 1999
	V7.4

(See /get_spddisc.pro)


GET_SYSDATE

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	GET_SYSDATE
 PURPOSE:
	Return the current date in YYYY-MM-DD format.  This is the format
	required by the DATE keywords in a FITS header (Y2K compliant)

 CALLING SEQUENCE:
	GET_SYSDATE, sysdate
 INPUTS:
	None
 OUTPUTS:
	sysdate = A ten character scalar string specifying the year followed 
		  by the current month (1-12) and the current day 
		  (eg "1999-03-27")

 EXAMPLE:
	Add the current date to the DATE keyword in a FITS header,h
     
	IDL> GET_SYSDATE, sysdate
	IDL> addpar2hdr, h, 'DATE', sysdate

 REVISION HISTORY:
	Written      by WMT/DIAS	Feb 1996
	Y2K Compliance (CG)		Jun 1999
	V7.4

(See /get_sysdate.pro)


GET_WHEELS

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	GET_WHEELS

 PURPOSE:
	Get the wheels positions corresponding to tmpdata from the 
	Compact Status structure. Get also measurement time, number
	of destructive read-outs per chopper cycle and integration time
	on the capacitor.

 CATEGORY:
	PIA - processing

 CALLING SEQUENCE:
       GET_WHEELS, Measname, Wheels, Meast, Dr, Intt

 INPUTS:
       Measname: A PHT measurement name (admn)

 OUTPUTS:
       Wheels: A 3 array containing the wheel positions (absolute order)
	Meast:	Measurement time
	Dr:	Number of destructive read-outs
	Intt:	Integration time 

 COMMON BLOCKS:
	phtcs

 PROCEDURES USED:
	PIA LIB: read_cs

 MODIFICATION HISTORY:
       Written by:	Carlos Gabriel
	Oct 95 Version 3.5

(See /get_wheels.pro)


GGT

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	GGT

 PURPOSE:
	This function calculates largest common divisor of two numbers.

 CATEGORY:
	General Mathematics

 CALLING SEQUENCE:
	Result = GGT(N,M)

 INPUTS:
	N, M:	Two numbers of which the LCD is required

 OUTPUTS:
	RESULT:	The largest common divisor of N and M.

 PROCEDURES USED:
	None

 MODIFICATION HISTORY:
	Written by:	D. Skaley
	Oct 95 Version 3.5
	Avoiding endless loop (CG)		December 1995

(See /ggt.pro)


GIVE_CS

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	GIVE_CS

 PURPOSE:	
	Bring back CS data from phtcs and determine
	corresponding record to tmpdata 

 CATEGORY:
	PIA - I/O

 CALLING SEQUENCE:
	GIVE_CS, tmpdata, cst, record, [conv_cst,] error=error

 INPUT PARAMETERS:
	tmpdata: A valid PHT IA measurement structure (ERD, SRD, ...)  

 OUTPUT:
	cst: 	unconverted compact status structure (as under phtcs.handle)
	record:	record corresponding to tmpdata within the CS structure
	conv_cst: converted compact status structure	 

 OUTPUT KEYWORDS:
	error: 1 if output invalid

 RESTRICTIONS:   tmpdata must be a valid PHT IA real or dynamical structure

 PROCEDURES USED:
       Common Block(s) or @ procedure(s):
               phtcs

 MODIFICATION HISTORY:
	Written by: C. Gabriel (ESA/VILSPA)		May 1997
	V6.3
	Conv_cst added as optional output (CG)		July 1997
	V6.4
	Reading CSfile if not in buffer (CG)		June 1999
	V7.4
	Avoiding crash if CS file had to be read (CG)	August 1999
	V8.0	

(See /give_cs.pro)


GLUE_AAP

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	GLUE_AAP

 PURPOSE:
	Concatenate two measurements on AAP level, accomodating the new
	produced pseudo-measurement into the phtaap buffer

 CATEGORY:
	PIA - processing

 CALLING SEQUENCE:
	GLUE_AAP, aap1, aap2, aapps, mednorm=mednorm, error=error	

 INPUTS:
	aap1		The first temporary AAP structure
	
	aap2		The second temporary AAP structure

 KEYWORD PARAMETERS:
	MEDNORM		An array (same dimension as detector pixels in the
			AAP structures) containing normalization values

	ERROR		Returns an error status:
			0 = no error
			1 = error: output arguments are not correct

 OUTPUTS:
	AAPPS		The position within the AAP buffer of the concatenated
			pseudo-measurement

 PROCEDURES USED: 
	(none)

 COMMON BLOCKS:
	(none)

 ASSUMPTIONS:
	AAP1 and AAP2 are aap temporary structures corresponding to the
	same detector

 MODIFICATION HISTORY:
	Written by: 		
	C. Gabriel (ESA-VILSPA SAI)			December 1997
	V6.6
	Including concatenation information on header,
	 & avoiding long measurement names (CG)		July 1998
	V7.2 

(See /glue_aap.pro)


GNO2DEG

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	GNO2DEG

 PURPOSE:
	GNO2DEG converts pixel indices I_RA and I_DEC in a gnonomic projection
	into RA and DEC in degrees assuming a projection center [RA0, DEC0].
	Pixel [0,0] is assumed to be in the lower left corner.

 CATEGORY:
       Astronomy.

 CALLING SEQUENCE:
	GNO2DEG, I_RA, I_DEC, RA0, DEC0, SCALE, N_RA, N_DEC, RA, DEC

 INPUTS:
	I_RA:	Int/Flt scalar or array; specifying the index/indices of the
		specified position(s) in RA-direction.
	I_DEC:	Int/Flt scalar or array; specifying the index/indices of the
		specified position(s) in DEC-direction.
	RA0:	Float scalar; specifying the projection center's right
		acsension [degrees].
	DEC0:	Float scalar; specifying the projection center's declination
		[degrees].
	SCALE:	Float scalar; specifying the number of pixels per degree.
		[degrees^-1].
	N_RA:	Int scalar; specifying the number of pixels in RA-direction.
	N_DEC:	Int scalar; specifying the number of pixels in DEC-direction.

 OPTIONAL INPUT PARAMETERS:
       None.

 OPTIONAL INPUT KEYWORDS:
	None.

 OUTPUTS:
	RA:	Float scalar or array; containing the right ascension(s)
		[degrees].
	DEC:	Float scalar or array; containing the declination(s) [degrees].

 OPTIONAL OUTPUT PARAMETERS:
	None.

 OPTIONAL OUTPUT KEYWORDS:
	None.

 COMMON BLOCKS:
	None.

 SIDE EFFECTS:
       None.

 RESTRICTIONS:

 MODIFICATION HISTORY:
       created by: Stefan Bogun            MPIA Heidelberg
       	    March, 1995

(See /mapaap2drizzle.pro)


GS_LIN[1]

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	GS_LIN

 PURPOSE:
	Evaluate the sum of a Gaussian and a 1st-order polynomial
	and optionally return the value of its partial derivatives.
	Normally, this function is used by CURVEFIT to fit the
	sum of a line and a varying background to actual data.

 CATEGORY:
	E2 - Curve and surface fitting.

 CALLING SEQUENCE:
	GS_LIN, X, A, F [, Pder]

 INPUTS:
	X:	The values of the independent variable.
	A:	The parameters of the equation described in PROCEDURE below.

 OUTPUTS:
	F:	The value of the function at each X(i).

 OPTIONAL OUTPUT PARAMETERS:
	Pder:	An array of the size (N_ELEMENTS(X),5) that contains the
		partial derivatives.  Pder(i,j) represents the derivative
		at the i'th point with respect to j'th parameter.

 COMMON BLOCKS:
	None.

 SIDE EFFECTS:
	None.

 RESTRICTIONS:
	None.

 PROCEDURE:
	F = A(0)*EXP(-Z^2/2) + A(3) + A(4)*X 
	Z = (X-A(1))/A(2)

 MODIFICATION HISTORY:
	Written by P. Merluzzi                        September 1995

(See /gs_lin.pro)


GS_LIN[2]

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	GS_LIN

 PURPOSE:
	Evaluate the sum of a Gaussian and a 1st-order polynomial
	and optionally return the value of its partial derivatives.
	Normally, this function is used by CURVEFIT to fit the
	sum of a line and a varying background to actual data.

 CATEGORY:
	E2 - Curve and surface fitting.

 CALLING SEQUENCE:
	GS_LIN, X, A, F [, Pder]

 INPUTS:
	X:	The values of the independent variable.
	A:	The parameters of the equation described in PROCEDURE below.

 OUTPUTS:
	F:	The value of the function at each X(i).

 OPTIONAL OUTPUT PARAMETERS:
	Pder:	An array of the size (N_ELEMENTS(X),5) that contains the
		partial derivatives.  Pder(i,j) represents the derivative
		at the i'th point with respect to j'th parameter.

 COMMON BLOCKS:
	None.

 SIDE EFFECTS:
	None.

 RESTRICTIONS:
	None.

 PROCEDURE:
	F = A(0)*EXP(-Z^2/2) + A(3) + A(4)*X 
	Z = (X-A(1))/A(2)

 MODIFICATION HISTORY:
	Written by P. Merluzzi                        September 1995

(See /lin.pro)


IA_START

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	IA_START

 PURPOSE:
	To initialize the Interactive Analysis with the relevant 
	parameters from Calibration G files or elsewhere, which 
	do not change at all or just do it infrequently

 CATEGORY:
	PIA - initialisation

 CALLING SEQUENCE:
	IA_START

 INPUTS:
	None

 OUTPUTS:
	None

 COMMON BLOCKS:
               adm
               adm_init
               colour_indices
               phtaap
               phtcla
               phtcs
               phtdarkcur
               phtdietrans
               phterd
               phtfilter_prop
               phtiiph
               phtscp
               phtsm
               phtsmc
		gencho_sm
               phtspd
               phtsrd
		
 PROCEDURE:
	Calibration G files are used eventually together with parameters
	which are direcly written into this routine and do not change
	frequently. 

 PROCEDURES USED:
	PIA LIB: darkcur_init
	         darkcur_str_init
	         die_trans_init
	         fcspow_str_init
	         phtcap_init
	         phtfilter_prop_init
	         respons_str_init
	         scp_init
	         set_colours
	         smc_init
	         spd_init
	         srd_init
	         write_acc

	         phtaap_init (batch file)
	         phtcla_init (batch file)
	         phtcs_init (batch file)
	         phterd_init (batch file)
	         phtiiph_init (batch file)
	         phtscp_init (batch file)
                phtsm_init (batch file)
	         phtsmc_init (batch file)
	         gencho_sm_init (batch file)
	         phtspd_init (batch file)
	         phtsrd_init (batch file)

 MODIFICATION HISTORY:
	Written by:	Carlos Gabriel, ESA/VILSPA	October 1995
	Modified (last) by CG				January 1997
	V5.5.1
	Initialisation of PIA_BUFINFO added to avoid
	 problems (CG)					May 1997
	V6.3 
	Initialisation of "zoom" variables (CG)		October 1997
	V6.5
	Initialisation of signal fractions discard (CG)
	 and inclusion of cal.menues init (JA)		January 1998
	V7.0
	Initialisation of dynamic calibration CBs (CG)	November 1998
	V7.3
       

(See /ia_start.pro)


IBCKSUB_PARAM

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	ibcksub_PARAM

 PURPOSE:
	This is not an IDL routine as such, but contains the definition of the
	common block DEGLITCH_PARAM for inclusion into other routines.  By 
	defining the common block in one place, the problem of conflicting 
	definitions is avoided.

	This file is included into routines that need this common block with
	the single line (left justified)

				  @ibcksub_param

	This file stores the parameters for the background  routine:
	
	   

 CATEGORY:
	PIA - common block

 MODIFICATION HISTORY:
	Written by:	J.Acosta  				April 1998
	V7.1

(See /ibcksub_param.pro)


IBCKSUB_PARAM_INIT

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	IBCKSUB_PARAM_INIT

 PURPOSE:
	Initialise the ibcksub_param common block

 CATEGORY:
	PIA - initialisation

 CALLING SEQUENCE
	IBCKSUB_PARAM_INIT

 INPUTS:
	None

 OUTPUTS:
 	None

 COMMON BLOCKS:
	ibcksub_params

 SIDE EFFECTS:
	The values of the ibcksub_params common block are initialised

 PROCEDURES USED:
 	None

 MODIFICATION HISTORY:
	Written by:	Jacosta					April 1998
	V7.1

(See /ibcksub_param_init.pro)


ID2WHEELS

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       ID2WHEELS

 PURPOSE:
       Returns the wheels corresponding to filter and aperture id's 

 CATEGORY:
	PIA - processing

 CALLING SEQUENCE:
	id2wheels, det, filt_id, aper_id, wheels, lambda, area

 INPUT:
	det:		Detector name
	filt_id:	Official filter identifier - (string)      
	aper_id:	Official aperture identifier - (string)       
	wheels:		3-array containing the wheel positions

 OUTPUT:
	wheels:		3-array containing the wheel positions

 OPTIONAL OUTPUT:
	lambda:		Central Wavelength
	area:		Aperture area (in mm^2)

 COMMON BLOCKS:
	phtapertures:	Apertures and their sizes
	phtfilter:	Filters' IDs

 MODIFICATION HISTORY:
       Written by: Carlos GABRIEL (ESA-SAI)	November 1995
	Bug with C filters fixed (CG)		December 1995
	STRTRIM used for filters ID (CG)	February 1996
	phtapert used now (CG)			February 1998
	V7.0

(See /id2wheels.pro)


INTERPOL_FPGC

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	INTERPOL_FPGC

 PURPOSE:
	Interpolate Focal Plane Geometry Calibration File coordinates form
	x,y raster coordinates
	A linear interpolation between the two FPGC coordinates above and 
	below the given raster coordinates is performed.

 CALLING SEQUENCE:
	interpol_fpgc, infile, x, y, scy, scz, ERROR=error

 INPUT:
 	infile: name of FPGC file
	x: raster x-coordinate as from PIA
	y: raster y-coordinate as from PIA

 OUTPUT:
	scy: FPGC coordinate interpolated to correspond to raster x coordinate
	scy: FPGC coordinate interpolated to correspond to raster x coordinate

 OPTIONAL INPUT:
	none

 KEYWORD PARAMETERS:
	ERROR		Returns an error status:
			0 = no error
			1 = error: output is not valid

 PROCEDURES USED:
	read_fpgc

 CALLED ROUTINES:
	read_fpgc	

 MODIFICATION HISTORY:
       Written by I. Heinrichsen                            Jul. 1995

(See /interpol_fpgc.pro)


INT_TO_TEXT

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       INT_TO_TEXT

 PURPOSE:
       To convert idb element number i of the status part  
       into an string array hkout containing the converted
       status data

 CATEGORY:
	PIA - processing

 CALLING SEQUENCE:
       Result = INT_TO_TEXT, Idb, Conv_table, Hkdat, I 

 INPUTS:
       Idb         :database array
       I           :idb element number (must be in STS part)
       Hkdat       :array containing the fits data
       Conv_table  :conversion table for element i

 OUTPUTS:
       Returns a string array containing the converted status data

 PROCEDURE:
       Add two one byte words to one two byte word, look
       for the bits dtermined by length and offset in the
       idb with the idb and function.
       Look for corresponding value in conv_table.        

 PROCEDURES USED:
       None

 MODIFICATION HISTORY:
       Written by:	Andreas Karch
	Oct 95 Version 3.5

(See /int_to_text.pro)


ISNUMBER

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       ISNUMBER
 PURPOSE:
       Determine if a text string is a valid number.
 CATEGORY:
 CALLING SEQUENCE:
       i = isnumber(txt, [x])
 INPUTS:
       txt = text string to test.                      in
 KEYWORD PARAMETERS:
 OUTPUTS:
       x = optionaly returned numeric value if valid.  out
       i = test flag:                                  out
           0: not a number.
           1: txt is a long integer.
           2: txt is a float.
           -1: first word of txt is a long integer.
           -2: first word of txt is a float.
 COMMON BLOCKS:
 NOTES:
 MODIFICATION HISTORY:
       R. Sterner.  15 Oct, 1986.
       Johns Hopkins Applied Physics Lab.
       R. Sterner, 12 Mar, 1990 --- upgraded.
       Richard Garrett, 14 June, 1992 --- fixed bug in returned float value.

 Copyright (C) 1986, Johns Hopkins University/Applied Physics Laboratory
 This software may be used, copied, or redistributed as long as it is not
 sold and this copyright notice is reproduced on each copy made.  This
 routine is provided as is without any express or implied warranties
 whatsoever.  Other limitations apply as described in the file disclaimer.txt.

(See /mapaap2drizzle.pro)


IS_FILE_EXIST

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       IS_FILE_EXIST

 PURPOSE:
       This is part of the pia support routines.
	It is used for checking if a file exist

 CATEGORY:
       PIA - utilities

 CALLING SEQUENCE:
       IS_FILE_EXIST, FILE

 INPUT:
	FILE: filename to check
 OUTPUT:

 COMMON BLOCKS:

 PROCEDURES USED:
       PIA LIB:
	Astronomical Library:
 MODIFICATION HISTORY:
	Written by: Wai-Ming Tai (DIAS)			Sept 1996
	Not official bug-fixing for VMS (CG)		Jul 1998

(See /is_file_exist.pro)


IS_NUM

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	IS_NUM

 PURPOSE:
	Function to determine if character is numerical
 	returns 1 if numerical
 	returns -1 if not

 CATEGORY:
	PIA - processing

 CALLING SEQUENCE:
	IS_NUM(string)

 INPUT:
	string:		(string) any single character string

 KEYWORD PARAMETERS:	
	none

 OUTPUT:
	function:	(integer) as defined above

 COMMON BLOCKS:

 RESTRICTIONS:

 PROCEDURES USED:	


 EXAMPLE:

 MODIFICATION HISTORY:
	Written by:	Bernhard Schulz
	21/03/97	first version		BS

(See /is_num.pro)


LINEAR_COR

[Previous Routine] [Next Routine] [List of Routines]
  NAME:
	LINEAR_COR

  PURPOSE:
	Corrects the non-linearities of the integration ramps

  CATEGORY:
	PIA - processing

  CALLING SEQUENCE:
	LINEAR_COR, Subinst, In_volt, Pixel, Freq, Out_Volt, Error
 
  INPUTS:
	SubInst: Phot subinstrument identifier string:
	   C1:PHT-C100  C2:PHT-C200  P:PHT-P    S:PHT-S
	In_Volt: Input voltages array corresponding to the pixel
	Pixel: Pixel number to correct for, in the same order as the SPD. 
	   (For PHT-P, corresponds to the different detectors: 
	   0: P1  1: P2  2:P3)
	Freq: The frequency of the measurement:
	   0: 1KHz   1: 4KHz  2: 8KHz

  OUTPUTS:
	Out_Volt: Array of corrected voltages per pixel/detector
	Error: Array of associated uncertainties

  COMMON BLOCKS:
	phtcrelin

  PROCEDURES USED:
	PIA LIB: read_crelin

  MODIFICATION HISTORY:
	Written by:	Huw Morris
	Modified by:	C. Gabriel
	Oct 95 Version 3.5
	Bug on error interpolation fixed (CG)		April 1996
	

(See /linear_cor.pro)


LIN_VOLTAGES

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	LIN_VOLTAGES

 PURPOSE:
	Apply voltage linearization onto a phterd structure 

 CATEGORY:
	PIA - processing

 CALLING SEQUENCE:
	LIN_VOLTAGES, Tmperd, Tmphdr, Silent=silent

 INPUTS:
	Tmperd:	A temporary PHTERD structure
	Tmphdr: The header to be modified 
	
 OUTPUTS:
	Tmperd: The temporary structure after voltage linearization
	Tmphdr: The modified header
	
 INPUT KEYWORD:
	Silent: Avoid window messages if set 

 COMMON BLOCKS:
	phtcs
	
 PROCEDURES CALLED:
	PIA LIB: linear_cor
	         read_cs
	
	
 MODIFICATION HISTORY:
	Written by:	Carlos Gabriel (ESA-SAI)
	Oct 95 Version 3.5
	Keyword silent added (CG)		July 1996

(See /lin_voltages.pro)


MAKESYM

[Previous Routine] [Next Routine] [List of Routines]
  PROCEDURE:
	MAKESYM
  PURPOSE:
	Call USERSYM to create one of the below plot symbols.
  CALLING SEQUENCE:
  	Makesym, SYMBOL
  INPUTS:
	SYMBOL - number indicating which symbol you want.  If not within the 
	range of available symbols, nothing is done.
	9  - Circle
	10  - Filled Circle
	11 - Filled Diamond
	12 - Filled Triangle
	13 - Filled Square
	14 - 5-point star
	15 - Filled 5-point star
	16 - Pentagon
	17 - Filled pentagon
	18 - Hexagon
	19 - Filled Hexagon
  OUTPUTS:
	None.
	USERSYM is called, which sets the default user plot symbol.
  Restrictions:
	Does not account for the histogram plotting style.
  History:
	Joel D. Offenberg, Hughes STX, 21 Jan 1993
	Added symbols 14-19.  JDO, March 1994

(See /makesym.pro)


MANN

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
     MANN

 PURPOSE:
       Perform Trend-test by Mann

 CATEGORY:
	PIA - processing

 CALLING SEQUENCE:
	mann, y, alpha, test

 INPUTS:
	y: 	array of data to be tested for trend (time sequence)
	alpha: 	certainty level for test

 KEYWORD PARAMETERS:

	Ctest		Test statistics parameter for Y,
			for use with Kendall statistics
	Cstar		Criticality parameter for C, alpha
	Ualpha		Quantile for confidence level alpha
	ERROR		Returns an error status:
						0 = no error
						1 = error: output is not valid
	optimize	If set and number of elements > 128, reduction by
			taking averages of neighbour elements

 OUTPUTS:
	tu:	true, if upward trend confirmed with alpha confidence
		false, otherwise
	td:	true, if downward trend confirmed with alpha confidence
		false, otherwise	

 PROCEDURES CALLED
	INTERNAL:	sign
			hast

 RESTRICTIONS
	The number of elements of the tested array must be grater than 10

 MODIFICATION HISTORY:
       Written by:	Ingolf Heinrichsen (MPIK)		Nov. 95
	Limit of at least 10 points relaxed to 7 (CG)		January 1996

(See /mann.pro)


MAPAAP2DRIZZLE

[Previous Routine] [Next Routine] [List of Routines]
 NAME:  MapAAP2Drizzle

 PURPOSE:
       Make Drizzle Script for IRAF from ISOPHOT / PIA / IAAP - Map Data

 VERSION: Jan. 20, 1999

 CATEGORY:
       ISOPHOT, Image Analysis

 CALLING SEQUENCE:
       MapAAP2Drizzle,    FileName_or_FileList

 INPUTS:
       FileName_or_FileList : Name of IAAP DiskFileName (CharacterString !)
                                                     or
                              List of IAAP Disk filenames (CharacterArray !)

 KEYWORD PARAMETERS:
      ScriptName         : (List of)Diskfilename(s) for IRAF Script(s)
      ImageName          : Name of IRAF image (= map) to be created by script
      IRAFCommandName    : Name of file with IRAF commands
      Identifier         : Identifier keyword of map
      Scale              : Ratio of final to original image pixel size
      MapPixelSize       : final image pixel size (map pixel size) in arcsec
      PositAngle         : Astron. Position Angle of Y-axis of final image
                           (degrees ccw, = 0 means RA / Dec coordinate system)
      DrizzleFraction    : Scalefactor for Drizzle's drop size relative
                           to the detector pixel size
      MapRACenter,
      MapDECCenter       : predefined RA / DEC of map center
      OutImageExtend     : increase no of pixels of OutputImage
      NPixX              : size of final map in X direction
      NPixY              : size of final map in Y direction
      FillValue          : predefined value for empty pixels in the output map
      IgnorePixel        : ISOPHOT pixel indeces to be ignored for mapping
      Parallel           : no of parallel stripes (2, 4, 8, 16, etc...) for
                           hierarchical processing of non-overlapping stripes
                           scripts of the same level can be run in parallel
      DetectorFlatField  : multiplicative (!) flatfield correction factors
                           for each detector pixel;
                           to be applied to the detector fluxes/surf.brightnesses
      AAPGlobalFlatField : multiplicative (!) global flatfield correction factors
                           for each AAP file;
      /AddScaleToName    : File/Script names contain image scale
      /SurfaceBrightness : result is in surf. brightness instead of fluxes
      /Flux              : result is in units of flux (Default !)
      /Meanvalues,
      /Medianvalues      : use the Means or the Medians from PIA AAP structure
      /SingleAAP         : each input IAAP files gets its own script file
      /EveryPixel        : one script and map for each detector pixel
      /SimpleProjection  : output image is made using simple RA/DEC projection
      /GnomonicProjection: output image is made using gnomonic RA/DEC projection (Default!)
      /Spacecraftcoords  : align map along ISO spacecraft Y-Z system
      /IgnoreRollAngle   : pixel rollangle not used for mapping
      /OutputFrameShifts : Shifts are computed in output frame
      /FITS              : IRAF scripts automagically write FITS files
      /EXECUTE           : immediately start IRAF map making from within IDL
      /DEBUG             : make some debuging output

 OUTPUTS:
       none; IRAF Script(s) is/are written to disk file(s)

 EXAMPLES:
    MapAAP2Drizzle , ['C20144301205pai.IAAP'] , Scale=0.222222, /GNOMONIC

    MapAAP2Drizzle , ['C10144301206paiflt.IAAP'] , /GNOMONIC, MapPixelSize=10., /EXEC, /FITS

 NOTES:
    Requires IRAF V 2.11 and STSDAS 2.0.1
    Load all of the following from IRAFs login.cl before startup :
           stsdas
           toolbox
           imgtools
           analysis
           dither

 MODIFICATION HISTORY:

       (C)  M. Stickel    1997-1999    MPIA / IDC  1997-1999

                6. August 97  : intial Version
               17. August 97  : final image NOT aligned along RA / DEC ;
                                usage of RollAngle and external Position
                                Angle in drizzle
               10. October 97 : usage of PIA  Mean / Median fluxes
                                surface brightnesses
               13. October 97 : Single mode : for each datafile a scriptfile
               17. October 97 : Parallel mode : non-overlapping regions
                                drizzled in parallel
                                (basic idea suggested by Sibylle Peschke)
               16. November 97 : Process results of ParallelMode also in Parallel
               28. November 97 : A complete map for each pixel
               29. November 97 : FlatField Correction factors for each pixel
                2. December 97 : Calling Sequence put into header of script(s)
                7. December 97 : external definition of MapCenter coordinates
               02. February 98 : ask IRAF to write out FITS files
               11. March    98 : use average Rollangle for Image in Y/Z system
               09. Sept.    98 : artificial increase of output image size
               03. Nov.     98 : now standalone, no more PIA necessary
                                 if changes in pixel/aperture size are
                                 necessary, see subroutine 'MakePixelCoord'
               03. Nov.     98 : adapted to STSDAS DRIZZLE Version 1.2 (February 1998)
               16. Nov.     98 : ignore selected pixels for map making
               25. Nov.     98 : user defined map size
               07. Dec.     98 : add image scale to names of script/image file
               17. Dec.     98 : add projection header keywords
               21. Dec.     98 : add identifier parameter / keyword to header
               02. Jan.     99 : gnomonic projection now default,ignore rollangle,
                                 user-defined map pixel size [arcsec] ;
                                 global aap rescaling fixed; general clean-up
               18. Jan.     99 : direct IRAF start
               20. Jan.     99 : fillvalue added

		27. May      99 : wfits command with *.imh to avoid error (CG) 
		28. May      99 : keywords changed for using discrimination (CG) 

             THIS SOFTWARE COMES WITH ABSOLUTELY NO WARRANTY !!

(See /mapaap2drizzle.pro)


MERGEHDR

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	MERGEHDR

 PURPOSE:
 	Merge the primary header and the extended header, note that the NAXIS
 	line in the primary header is taken out.
	the hdr could be either a byte array or string array

 CATEGORY:
	PIA - processing

 CALLING SEQUENCE:
	MERGE_HDR, P_hdr, E_Hdr, H

 INPUTS:
	P_hdr: primary header in byte array or string array
	E_hdr: extended header in byte array or string array

 OUTPUTS:
	H: merged header, NAXIS line and the END line in the primary header 
          is taken out. Also taken out are the trailing blank lines in the
          raw byte array.

 PROCEDURES USED:
	None

 MODIFICATION HISTORY:
 	Written by:	W. M. Tai
	Modified (last) by CG
	Version 5.x - November 96

(See /mergehdr.pro)


MKRIPID

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	mkripid

 PURPOSE:
 	Generate RPID values for SCP internal file, add attitude keywords and
	correct chopper position

 CATEGORY:
          PIA - support

 CALLING SEQUENCE:
 	mkrpid, file, npoints, nlines, dpts, dlns, rota, nmeas, ngap, $
		addchop, pixel=pixel, inverse=inverse

 INPUTS:
	file:		name of PIA internal SCP file
	npoints:	number of raster points
	nlines:		number of raster lines
	dpts:		distance between raster points (arcsec)
	dlns:		distance between raster points (arcsec)
	rota:		rotaion angle of raster w.r.t to north
	nmeas:		number of data points per valid measurement cycle on a
			raster point
	ngap:		number of data points in gap between raster points
	addchop:	shift chopper position (arcsec)

 KEYWORD PARAMETERS:
	pixel:		pixel number
	inverse:	indicates whether raster is asumed in standard or
			revese direction  
	
 OUTPUTS:
	routine read "file" and changes it according to specifiedd parameters

 PROCEDURES USED:
       ASTRO LIB:
		fxaddpar

 EXAMPLE:
	Add the raster point id into the file P10001700501.ISRD with the raster
	parameters for a 9x9 raster with 30arcsec separation. There is a
	sequence of 300 valid data points and 100 gap points for every raster
	point/ slew combination. The chopper is not corrected.

	mkrpid, "P10001700501.ISRD", 9, 9, 30, 30, 45, 300, 100, 0

 MODIFICATION HISTORY:
 	Written by:	Detlef Skalay (MPIK)
	Oct 95 Version 3.5
			

(See /mkrpid.pro)


MK_ATT_KEYS

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	mk_att_keys

 PURPOSE:
	add attitude keywords to the file headers
	
 CATEGORY:
          PIA - support

 CALLING SEQUENCE:
	MK_ATT_KEYS, level, tdtnr, npts, nlns, dpts, dlns, rota

 INPUTS:
	level:	PIA product level
	tdtnr: 	TDT number of product to be changed
	npts:	Number of points of raster map
	nlns:	Number of lines in raster map
	dpts:	Distance (arcsec) between raster points
	dlns:	Distance (arcsec) between raster lines
	rota:	Rotational angle of raster map w.r.t. north direction

 OUTPUTS:
	The routine changes the related product file, defined by the TDT and
	product type, on which it is applied on disk

 COMMON BLOCKS:
		phtaap
		phterd
		phtscp
		phtspd
		phtsrd

 PROCEDURES USED:
	PIA LIB:
		pia_multmeas
       ASTRO LIB:
		fxaddpar

 EXAMPLE:
	To add the missing attitude keywords into the srd product of TDT
	04300301. a 9x9 map with 30arcsec separationa and a rotation
	w.r.t to north of 45 deg is asumed.

	mk_att_keys, srd, 04300301, 9, 9, 30, 30, 45

 MODIFICATION HISTORY:
 	Written by:	Carlos Gabriel (ESA/ESTEC)
	Oct 95 Version 3.5
			

(See /mk_att_keys.pro)


NWRDS

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       NWRDS
 PURPOSE:
       Return the number of words in the given text string.
 CATEGORY:
 CALLING SEQUENCE:
       n = nwrds(txt)
 INPUTS:
       txt = text string to examine.             in
 KEYWORD PARAMETERS:
       Keywords:
         DELIMITER = d.  Set delimiter character (def = space).
 OUTPUTS:
       n = number of words found.                out
 COMMON BLOCKS:
 NOTES:
       Notes: See also getwrd.
 MODIFICATION HISTORY:
       R. Sterner,  7 Feb, 1985.
       Johns Hopkins University Applied Physics Laboratory.
       RES 4 Sep, 1989 --- converted to SUN.

 Copyright (C) 1985, Johns Hopkins University/Applied Physics Laboratory
 This software may be used, copied, or redistributed as long as it is not
 sold and this copyright notice is reproduced on each copy made.  This
 routine is provided as is without any express or implied warranties
 whatsoever.  Other limitations apply as described in the file disclaimer.txt.

(See /mapaap2drizzle.pro)


PAIR_DEGLITCH

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	Pair_deglitch

 PURPOSE:
	Flag glitched points within a measurement according to the 
	two thresholds deglitching algorithm.

 CATEGORY:
	PIA - processing

 CALLING SEQUENCE:
	pair_deglitch, tmpdata, med_width, thresh1, thresh2, niter, $
      			erd_disc, pixel, pdegl_flag

 INPUT:
	tmpdata:	A temporary ERD type structure
	med_width:	Width to be used for median filtering included in 
			 the baseline correction
	thresh1:	Threshold for primary glitch recognition
	thresh2:	Threshold for recognition of glitch tails
	niter:		Number of iterations for primary glitch recognition
	erd_disc:	Flag array corresponding to tmpdata.conp(pixel,*) 
			 (readout voltages corresponding to one pixel) with 
			 0's (accepted points) and 1's(discarded points).
	pixel:		Pixel to be analysed
 

 OUTPUT:
	pdegl_flag:	Array (as erd_disc) with glitch recognized positions
			 set to 5.

 RESTRICTIONS:
	tmpdata must be a valid temporary PHT-ERD type structure

 PROCEDURES CALLED:
       Astronomical Library:
               avg
		sigma
	PIA Libraries:
		decode_pixf
		get_rastersteps
		get_rpchopstep
		median_bb (thanks to JAP)  
 
 SIDE EFFECTS:
	Initializes the variable degltext in Common degl_string and fills it
	with statistical info.	

 MODIFICATION HISTORY
	Written by: Carlos GABRIEL (ESA/VILSPA-SAI)	        November 1997
	V7.0
	Avoiding raster/chopper combinations with too
	 few points (CG)				           March 1998
	V7.1
	Using pre-discarded points correctly (CG)	          June 1998
	V7.2
	Preventing for no valid points case (CG)	          August 1998
	V7.3
	Algorithm modified, a smoothed voltage differences
	 subtracted from the original differences + simplified 
	 finding of secondary glitches		JAcosta           May 1999 
	End condition corrected (CG)		CG		  May 1999
	V7.4

(See /pair_deglitch.pro)


PCONT_CHANGE_PATH

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       PCONT_CHANGE_PATH

 PURPOSE:
       This is part of the pia_control panel support routines.
 	And therefore is designed entirely with the pia_control,
	pia_read_ext and pia_man_mea in mind.
	It is used for changing the path when the user click on
	the Select File From in the pia_control or pia_read_ext.

 CATEGORY:
       PIA - utilities

 CALLING SEQUENCE:
       PCONT_CHANGE_PATH, WIDGET_HANDLE_ID, PAR, SEL_INDEX

 INPUT:
	WIDGET_HANDLE_ID: the handle structure for the control panel
	PAR: the parameter for the control panel
	SEL_INDEX: the selection index for the files, where
		0 = pipeline fits
		1 = pia fits
		2 = internal idl save file

 OUTPUT:

 COMMON BLOCKS:

 PROCEDURES USED:
       PIA LIB:
	  pcont_valid_dir
	  pcont_getdirs
	  pcont_getfiles
	Astronomical Library:
 MODIFICATION HISTORY:
	Written by: Wai-Ming Tai (DIAS)			March 1996
	Extension with PFITDIR (CG)			October 1997
	V6.5

(See /pcont_change_path.pro)


PCONT_CLEARMFILE

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       PCONT_CLEARMFILE

 PURPOSE:
       This is part of the pia_control panel support routines.
 	And therefore is designed entirely with the pia_control,
	pia_read_ext and pia_man_mea in mind.
	It is used for clearing the filelist in the multiple
	file list box. Mainly used after reading the files.

 CATEGORY:
       PIA - utilities

 CALLING SEQUENCE:
       PCONT_CLEARMFILE, ID, PAR, MFILELIST

 INPUT:
	ID: the structure for the widget handler in the pia_control or
	    the pia_read_ext.
	PAR: parameter

	MFILELIST: multiple file list

 OUTPUT:

 COMMON BLOCKS:

 PROCEDURES USED:
       PIA LIB:
	Astronomical Library:
 MODIFICATION HISTORY:
	Written by: Wai-Ming Tai (DIAS)			March 1996

(See /pcont_clearmfile.pro)


PCONT_CLRBUF

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       PCONT_CLRBUF

 PURPOSE:
       This is part of the pia_control panel support routines.
 	And therefore is designed entirely with the pia_control,
	pia_man_mea in mind.
	It is used for clearing the measurement buffer

 CATEGORY:
       PIA - utilities

 CALLING SEQUENCE:
       PCONT_CLRBUF, ID, MEA_PAR, MEALIST

 INPUT:
	ID: the structure for the widget handle, mainly for pia_control
		pia_man_mea
	MEA_PAR: the measurement parameter
	MEALIST: the measurement list

 OUTPUT:

 COMMON BLOCKS:

 PROCEDURES USED:
       PIA LIB:
	  yes_no
	  erd_init
	  srd_init
	  smc_init
	  scp_init
	  spd_init
	  cla_init
	  cs_init
	Astronomical Library:
 MODIFICATION HISTORY:
	Written by: Wai-Ming Tai (DIAS)			March 1996
	Modified (last) by CG 				October 1996
	V5.x
	Choice on meas to be deleted included (CG)	May 1997
	V6.3

(See /pcont_clrbuf.pro)


PCONT_FILTER

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       PCONT_FILTER

 PURPOSE:
       This is part of the pia_control panel support routines.
 	And therefore is designed entirely with the pia_control,
	pia_read_ext and pia_man_mea in mind.
	It is used for handling the file filter event in the
	pia_control and pia_read_ext.

 CATEGORY:
       PIA - utilities

 CALLING SEQUENCE:
       PCONT_FILTER, ID, FILTER

 INPUT:
	ID: the structure for the widget handle
	FILTER: the file filter
 OUTPUT:

 COMMON BLOCKS:

 PROCEDURES USED:
       PIA LIB:
	  pcont_getfiles
	Astronomical Library:
 MODIFICATION HISTORY:
	Written by: Wai-Ming Tai (DIAS)			March 1996

(See /pcont_filter.pro)


PCONT_GETDIRS

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       PCONT_GETDIRS

 PURPOSE:
       This is part of the pia_control panel support routines.
 	And therefore is designed entirely with the pia_control,
	pia_read_ext and pia_man_mea in mind.
	It is used for getting the subdirectory.

 CATEGORY:
       PIA - utilities

 CALLING SEQUENCE:
       PCONT_GETDIRS

 INPUT:
 OUTPUT:

 COMMON BLOCKS:

 PROCEDURES USED:
       PIA LIB:
	Astronomical Library:
 MODIFICATION HISTORY:
	Written by: Wai-Ming Tai (DIAS)			March 1996

(See /pcont_getdirs.pro)


PCONT_GETFILES

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       PCONT_GETFILES

 PURPOSE:
       This is part of the pia_control panel support routines.
 	And therefore is designed entirely with the pia_control,
	pia_read_ext and pia_man_mea in mind.
	It is used for getting the files with a given file filter.

 CATEGORY:
       PIA - utilities

 CALLING SEQUENCE:
       PCONT_GETFILES, FILTER

 INPUT:
	FILTER: the file filter
 OUTPUT:

 COMMON BLOCKS:

 PROCEDURES USED:
       PIA LIB:
	Astronomical Library:
 MODIFICATION HISTORY:
	Written by: Wai-Ming Tai (DIAS)			March 1996
	KEYWORD Sort added (CG)				February 1998
	V7.1

(See /pcont_getfiles.pro)


PCONT_MREMOVE

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       PCONT_MREMOVE

 PURPOSE:
       This is part of the pia_control panel support routines.
 	And therefore is designed entirely with the pia_control,
	pia_read_ext and pia_man_mea in mind.
	It is used for removing the file in the multiple file list
	in pia_control and pia_read_ext.

 CATEGORY:
       PIA - utilities

 CALLING SEQUENCE:
       PCONT_FILTER, ID, PAR, MFILELIST

 INPUT:
	ID: the structure for the widget handle
	PAR: the parameter
	MFILELIST: the multiple file list

 OUTPUT:

 COMMON BLOCKS:

 PROCEDURES USED:
       PIA LIB:
	Astronomical Library:
 MODIFICATION HISTORY:
	Written by: Wai-Ming Tai (DIAS)			March 1996

(See /pcont_mremove.pro)


PCONT_MSGLINE

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       PCONT_MSGLINE

 PURPOSE:
       This is part of the pia_control panel support routines.
 	And therefore is designed entirely with the pia_control,
	pia_read_ext and pia_man_mea in mind.
	It is used for printing the message on the message line.

 CATEGORY:
       PIA - utilities

 CALLING SEQUENCE:
       PCONT_MSGLINE, MSG, HMSGLINE

 INPUT:
	MSG: the message to print
	HMSGLINE: the widget handle for the message line

 OUTPUT:

 COMMON BLOCKS:

 PROCEDURES USED:
       PIA LIB:
	Astronomical Library:
 MODIFICATION HISTORY:
	Written by: Wai-Ming Tai (DIAS)			March 1996

(See /pcont_msgline.pro)


PCONT_READFILE

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       PCONT_READFILE

 PURPOSE:
       This is part of the pia_control panel support routines.
 	And therefore is designed entirely with the pia_control,
	pia_read_ext and pia_man_mea in mind.
	It is used for handling the read file event.

 CATEGORY:
       PIA - utilities

 CALLING SEQUENCE:
       PCONT_READFILE, ID, STYPE, FILENAME, PATH

 INPUT:
	ID: the structure for the widget handle
	STYPE: the selection type, (ie pipeline, pia fits or internal)
	FILENAME: the filename to read
	PATH: the path containing the file

 OUTPUT:

 COMMON BLOCKS:

 PROCEDURES USED:
       PIA LIB:
	  pia_read_fits
	  pia_read_ifile
	Astronomical Library:
 MODIFICATION HISTORY:
	Written by: Wai-Ming Tai (DIAS)			March 1996

(See /pcont_readfile.pro)


PCONT_REFRESH

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       PCONT_REFRESH

 PURPOSE:
       This is part of the pia_control panel support routines.
 	And therefore is designed entirely with the pia_control,
	pia_read_ext and pia_man_mea in mind.
	It is used for refreshing the content of the data type
	and the file selection box.

 CATEGORY:
       PIA - utilities

 CALLING SEQUENCE:
       PCONT_REFRESH, ID, SEL_PAR, PAR, SELECTION = SELECTION,
		UPDATE = UPDATE

 INPUT:
	ID: the structure for the widget handle
	SEL_PAR: the selection parameter
	PAR: the parameter
	
 OUTPUT:

 OPTIONAL INPUT:
	SELECTION: the selection index for the pipeline, pia fits or
		internal idl save file. A string type!
	UPDATE: to indicate this is just an update when user
		click on the file type box or the detectors box

 COMMON BLOCKS:

 PROCEDURES USED:
       PIA LIB:
	  pcont_getfiles
	  pcont_getdirs
	Astronomical Library:
 MODIFICATION HISTORY:
	Written by: Wai-Ming Tai (DIAS)			March 1996

(See /pcont_refresh.pro)


PCONT_SAVEFITS

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       PCONT_SAVEFITS

 PURPOSE:
       This is part of the pia_control panel support routines.
 	And therefore is designed entirely with the pia_control,
	pia_read_ext and pia_man_mea in mind.
	It is used for saving the measurement to the fits file

 CATEGORY:
       PIA - utilities

 CALLING SEQUENCE:
       PCONT_SAVEFITS, ID, DATATYPE, MLIST_INDEX, MEALIST

 INPUT:
	ID: the structure for the widget handle
	DATATYPE: the data type
	MLIST_INDEX: the index of the selected measurement 
	MEALIST: the measurement list
 OUTPUT:

 COMMON BLOCKS:
	  phtsrd
	  phtscp
	  phtspd
	  phtsmc

 PROCEDURES USED:
       PIA LIB:
	  pia_load_isrd
	  pia_load_iscp
	  pia_load_ispd
	  pia_sm_load_ismc
	  write_srd
	  write_scp
	  write_spd
	  write_smc
	  write_srd
	  pia_pickfile
	  pcont_msgline
	Astronomical Library:
 MODIFICATION HISTORY:
	Written by: Wai-Ming Tai (DIAS)			March 1996
       Modified by Stefan Bogun (MPIA)			August 1996
	V5.x	
	pia_pickfile1 replaced (CG)			February 1999 
	V7.4

(See /pcont_savefits.pro)


PCONT_SAVEINT

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       PCONT_SAVEINT

 PURPOSE:
       This is part of the pia_control panel support routines.
 	And therefore is designed entirely with the pia_control,
	pia_read_ext and pia_man_mea in mind.
	It is used for saving the measurement to the internal IDL
	save file.

 CATEGORY:
       PIA - utilities

 CALLING SEQUENCE:
       PCONT_SAVEINT, ID, DATATYPE, MEA_INDEX, MEALIST

 INPUT:
	ID: the structure for the widget handle
	DATATYPE: the data type
       MEA_INDEX: the index of the selected measurement 
       MEALIST: the measurement list
 OUTPUT:

 KEYWORDS:
	NO_BUFCONT: 	set if call not coming from buffer control
	TMPDATA:	the structure to be saved if not using buffer control

 COMMON BLOCKS:
         phtsrd
         phtscp
         phtspd
         phtsmc
	  phterd
	  phtcs

 PROCEDURES USED:
       PIA LIB:
	  pia_load_ierd
	  pia_load_isrd
	  pia_load_iscp
	  pia_load_ismc
	  pia_load_ispd
	  pia_load_ics
	  pia_load_idrift
	  pia_load_idynresp
	  pia_write_ics
	  pia_pickfile
	  pcont_msgline
	Astronomical Library:
 MODIFICATION HISTORY:
	Written by: Wai-Ming Tai (DIAS)			March 1996
	Save phtaap added (CG)				June 1996
       SMD out, SMC int (SB)                           August 1996
	Message added to SCP level, 
	 keyword NO_BUFCONT added +
	 saving for drift structure (CG)		May 1997
	V6.3
	pia_pickfile1 replaced (CG)			February 1999
	V7.4
	Saving phtdynresp included (JAcosta)		February 2000
	V8.2

(See /pcont_saveint.pro)


PCONT_SUBDIR

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       PCONT_SUBDIR

 PURPOSE:
       This is part of the pia_control panel support routines.
 	And therefore is designed entirely with the pia_control,
	pia_read_ext and pia_man_mea in mind.
	It is used for handling the subdirectories event

 CATEGORY:
       PIA - utilities

 CALLING SEQUENCE:
       PCONT_SUBDIR, ID, PAR, EVENT

 INPUT:
	ID: the structure for the widget handle
	PAR: parameter
	EVENT: the caller event
 OUTPUT:

 COMMON BLOCKS:

 PROCEDURES USED:
       PIA LIB:
	  pcont_valid_dir
	Astronomical Library:
 MODIFICATION HISTORY:
	Written by: Wai-Ming Tai (DIAS)			March 1996
	Extension with PFITDIR (CG)			October 1997
	V6.5

(See /pcont_subdir.pro)


PCONT_UPDATEMEA

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       PCONT_UPDATEMEA

 PURPOSE:
       This is part of the pia_control panel support routines.
 	And therefore is designed entirely with the pia_control,
	pia_read_ext and pia_man_mea in mind.
	It is used for updating the measurement list

 CATEGORY:
       PIA - utilities

 CALLING SEQUENCE:
       PCONT_UPDATEMEA, DATATYPE, DET, ID, MEA_PAR, MEALIST

 INPUT:
	ID: the structure for the widget handle
	DATATYPE: the datatype
	DET: the detectors
	MEA_PAR: the measurement parameter
	MEALIST: the measurement list
 OUTPUT:

 COMMON BLOCKS:
	  phterd
	  phtsrd
	  phtscp
	  phtspd
	  phtsmc
	  phtcla

 PROCEDURES USED:
       PIA LIB:
	  decode_tdt2mea
	  decode_hdr2mea
	  decode_cs2mea
	Astronomical Library:
 MODIFICATION HISTORY:
	Written by: Wai-Ming Tai (DIAS)			March 1996
       Modified by Stefan Bogun (MPIA)			August 1996
	V5.x	

(See /pcont_updatemea.pro)


PCONT_VALID_DIR

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       PCONT_VALID_DIR

 PURPOSE:
       This is part of the pia_control panel support routines.
 	And therefore is designed entirely with the pia_control,
	pia_read_ext and pia_man_mea in mind.
	It is used for checking if a directory is valid

 CATEGORY:
       PIA - utilities

 CALLING SEQUENCE:
       PCONT_VALID_DIR, DIR

 INPUT:
	DIR: directory path
 OUTPUT:

 COMMON BLOCKS:

 PROCEDURES USED:
       PIA LIB:
	Astronomical Library:
 MODIFICATION HISTORY:
	Written by: Wai-Ming Tai (DIAS)			March 1996

(See /pcont_valid_dir.pro)


PCONT_VIEWHDR

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       PCONT_VIEWHDR

 PURPOSE:
       This is part of the pia_control panel support routines.
 	And therefore is designed entirely with the pia_control,
	pia_read_ext and pia_man_mea in mind.
	It is used for viewing the external fits header

 CATEGORY:
       PIA - utilities

 CALLING SEQUENCE:
       PCONT_VIEWHDR, SELECTION, ID, FILETYPE, FILENAME, GROUP=GROUP

 INPUT:
	ID: the structure for the widget handle
	SELECTION: the selection for pipeline, pia fits or internal
	FILETYPE: the file type
	FILENAME: the filename
	
 OPTIONAL INPUT:
	GROUP: the event group
 OUTPUT:

 COMMON BLOCKS:
         phtsrd
         phtscp
         phtspd
         phtsmc
	  phterd
	  phtcla

 PROCEDURES USED:
       PIA LIB:
	  pia_view_txt
	  pcont_msgline
	Astronomical Library:
	  fxhread
 MODIFICATION HISTORY:
	Written by: Wai-Ming Tai (DIAS)			March 1996
       Modified by Stefan Bogun (MPIA)			August 1996
	V5.x	

(See /pcont_viewhdr.pro)


PCONT_VMEAHDR

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       PCONT_VMEAHDR

 PURPOSE:
       This is part of the pia_control panel support routines.
 	And therefore is designed entirely with the pia_control,
	pia_read_ext and pia_man_mea in mind.
	It is used for viewing the measurement's fits header

 CATEGORY:
       PIA - utilities

 CALLING SEQUENCE:
       PCONT_VMEAHDR, THEMEA, DET, GROUP=GROUP

 INPUT:
	THEMEA: index of the measurement in the relevant structure
	DET: the detector type
	
 KEYWORDS:
	GROUP: the event group
	NAMING: the name provided by the user
	GET: get the name provided by the user

 OUTPUT:

 COMMON BLOCKS:
         phtsrd
         phtscp
         phtspd
         phtsmc
	  phterd
	  phtcla

 PROCEDURES USED:
       PIA LIB:
	  pia_disp_hdr
	Astronomical Library:
 MODIFICATION HISTORY:
	Written by: Wai-Ming Tai (DIAS)			March 1996
       SMD out, SMC int (SB)                           August 1996
	Display chosen measurement fixed (CG)		May 1997
	V6.3
	Keyword GET added to obtain current name (JA)   December 1997
	V6.6
	Input argument is now the index in the array 
	not the admn anymore (JA)			January 1998

(See /pcont_vmeahdr.pro)


PHOTOM_INIT

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	PHOTOM_INIT

 PURPOSE:
	This routine takes the required values from the phtaap common
	block and builds them into a text array.

 CATEGORY:
	PIA - Processing

 INPUTS:
	Meas: An array of indices corresponding to measurements within
	      the phtaap common block

 KEYWORD:
	Colcor: colour correction to be applied - Colcor must be structure
		as defined by PIA_cc_defin

 OUTPUTS:
	Text: The text array
	Fname:  A string containing the _last_ observation TDT/Meas number
	      in a format suitable for a filename

 COMMON BLOCKS:
	phtaap

 PROCEDURES USED:
	None

 RESTRICTIONS:
	None

 MODIFICATION HISTORY:
	Written by:	Huw Morris
	Oct 95 Version ?.?
	Modified by:	Huw Morris	Jan 96
	Filters and apertures replaced by corresponding strings (CG)  Jan.96
	Polarizer replaced by corresponding string (CG)		February 1996
	Minor problems with output format fixed (Jacosta)	April 1997
	Colour correction (KEYWORD colcor) included (CG)	May 1997
	V6.3
	Format changed (avoid problems w. neg. fluxes) (CG)	July 1997
	V6.4
	PHTAPERT taken now (CG)					February 1998
	V7.0
	Displaying apertures in arcsec's (CG)			January 2000
	V8.2

(See /photom_init.pro)


PHTAAP

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	PHTAAP

 PURPOSE:
	Define the PIA Auto Analysis Product (AAP) common block.
 
 CALLING SEQUENCE:
	@phtaap

 CATEGORY:
          PIA - common block

 MODIFICATION HISTORY:
 	Written by:	Carlos Gabriel (ESA/ESTEC)
	phtaap_desc added (WMT)		May 1996
	Oct 95 Version 3.5

(See /phtaap.pro)


PHTAAP_INIT

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       phtaap_init
 PURPOSE:
       Initializes the structure PHTAAP defining the contents as
	a template structure PHTAAP_TYPE. 

 CATEGORY:
          PIA - initialization

 CALLING SEQUENCE:
       PHTAAP_INIT

 COMMON BLOCKS:
	phtaap

 MODIFICATION HISTORY:
       Written by C. Gabriel (ESA/ESTEC-SAI)		March 1995
	phtaap_desc added  (WMT)			May 1996
	aap_first_handle, aap_last_handle added		May 1996
	Central wavelength added (WMT)	 		Nov 1996
	DECP and RAP added by M. Hur (IPAC/Caltech)	Jan 2000
	V8.2

(See /phtaap_init.pro)


PHTAAR

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       PHTAAR

 PURPOSE:
       Definition of the common block PHTAAR (Auto Analysis Results) 
       for inclusion into other routines.


 CALLING SEQUENCE:
       @phtaar

 CATEGORY:
          PIA - common block

 COMMON BLOCK PARAMETERS:
	PPAP_TYPE: PHT-P point source photometry structure
	PPAE_TYPE: PHT-P extended source photometry structure
	PPAS_TYPE: PHT-P scan & slew photometry structure
	PLAP_TYPE: PHT-SL point source spectroscopy structure
	PLAE_TYPE: PHT-SL extended source spectroscopy structure
	PLAS_TYPE: PHT-SL Raster mode spectroscopy structure
	PSAP_TYPE: PHT-SS point source spectroscopy structure
	PSAE_TYPE: PHT-SS extended source spectroscopy structure
	PSAS_TYPE: PHT-SS Raster mode spectroscopy structure
	PCAP_TYPE: PHT-C point source photometry structure
	PCAE_TYPE: PHT-C extended source photometry structure
	PCAS_TYPE: PHT-C scan & slew photometry structure

 MODIFICATION HISTORY:
       Written by: Wai-Ming Tai (DIAS) Apr 1996
	FITS_... and *_DESC added (WMT) May 1996

(See /phtaar.pro)


PHTAAR_INIT[1]

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       PHTAAR_INIT

 PURPOSE:
       Definition of the PHTAAR structure for inclusion into other routines.

 CATEGORY:
       PIA - initialization

 CALLING SEQUENCE:
       @phtaar_init

 PROCEDURE:

 MODIFICATION HISTORY:
       Written by: Wai-Ming Tai (DIAS)           Apr, 1996
	Bug for PSAS and PLAS fixed (CG)	  Apr, 1998
V7.1
	Modifications for changed OLP9 products (CG)	Mar. 2000
V8.2

(See /phtaar_init.pro)


PHTAAR_INIT[2]

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       PHTAAR_INIT

 PURPOSE:
       Definition of the PHTAAR structure for inclusion into other routines.

 CATEGORY:
       PIA - initialization

 CALLING SEQUENCE:
       @phtaar_init

 PROCEDURE:

 MODIFICATION HISTORY:
       Written by: Wai-Ming Tai (DIAS)           Apr, 1996
	Bug for PSAS and PLAS fixed (CG)	  Apr, 1998
V7.1

(See /phtaar_pre9_init.pro)


PHTACC

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	PHTACC
 PURPOSE:
	Define common block ACC for information about acceptance/discarding 
	of data points.

 CATEGORY:
       PIA - common block

 CALLING SEQUENCE:
	@phtacc

 COMMON BLOCK PARAMETERS:
	NSELNDR : 1 if general NDR selection criteria used, 0 if not
	DRNACC	: 0 if DR to be accepted, 1 if not 
	NDR1NAC : 0 if first NDR to be accepted, 1 if not
	NDRNACC	: Array of NDRs (relative position within ramp) to be neglected
       MINR	: First Ramp (absolute position within meas) to be accepted
	MAXR  	: Last Ramp (absolute position) to be accepted
	ANYR	: Array of read-outs (absolute position) to be neglected 
	MINVOLT : Minimum voltage to be accepted
	MAXVOLT : Maximum voltage to be accepted
	SIGTNACC: Structure: {chop_meas:FLT,star_meas:FLT} indicating fraction
			      of chopper plateau discarded for chopped and
			      staring or raster measurements
	SIG1ACC : 0 if first Signal/Chopper Plateaux to be accepted, 1 if not
	SIGNACC	: Array of Signals (relative position within chopper plateaux)
		  to be neglected
	MINSIG	: First Signal (absolute position) to be accepted
	MAXSIG	: Last Signal (absolute position) to be accepted
	ANYSIG	: Array of Signals (absolute position) to be neglected 
	SCPNACC	: Array of contiguous Chopper Plateaux to be neglected
	MINCP	: First Chopper Plateau to be used
	MAXCP	: Last Chopper Plateau to be used
	ANYCP	: Array of individual (non-contiguous) Ch.Pl. to be neglected
	SPDNACC	: Array of cont. Chopper Plateaux (SPD level) to be neglected
	MINSCP	: First Chopper Plateau to be used (SPD level)
	MAXSCP	: Last Chopper Plateau to be used (SPD level)
	ANYSCP	: Array of individual (non-contiguous) Ch.Pl. to be neglected

 MODIFICATION HISTORY:
	Written by: Carlos Gabriel (ESA/ESTEC)
	Oct 95 Version 3.5

(See /phtacc.pro)


PHTAPERT

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	PHTAPERT

 PURPOSE:
	Definition of the common block APERTURE_SIZE for inclusion into
	other routines. This common block stores data about the phot
	aperture and pixels sizes and areas (mm, mm**2) and their
	shapes.  

 CATEGORY:
       PIA - common block

 CALLING SEQUENCE:
	@phtapert

 COMMON BLOCK PARAMETERS

         P_DIAMY : PHT-P Diameter(mm) of aperture in Y, fltarr(14,2),
                   fltarr(aperture, value/uncertainty)
         P_DIAMZ : PHT-P Diameter(mm) of aperture in Z, fltarr(14,2),
                   fltarr(aperture, value/uncertainty)
         P_AREA:   PHT-P Area(mm**2) of aperture, fltarr(14,2),
                   fltarr(aperture, value/uncertainty)
         P_Shape : PHT-P aperture shapes

         C1_DIAMY : PHT-C100 Diameter(mm) of pixel in Y, fltarr(2),
                    fltarr(value/uncertainty)
         C1_DIAMZ : PHT-C100 Diameter(mm) of pixel in Z, fltarr(2),
                    fltarr(value/uncertainty)
         C1_AREA:   PHT-C100 Area(mm**2) of pixel, fltarr(2),  
                    fltarr(aperture, value/uncertainty)

         C2_DIAMY : PHT-C200 Diameter(mm) of pixel in Y, fltarr(2),
                    fltarr(value/uncertainty)
         C2_DIAMZ : PHT-C200 Diameter(mm) of pixel in Z, fltarr(2),
                    fltarr(value/uncertainty)
         C2_AREA:   PHT-C200 Area(mm**2) of pixel, fltarr(2),  
                    fltarr(aperture, value/uncertainty)


 MODIFICATION HISTORY:
 	Written by: Ingolf Heinrichsen
       Jan 98 Version 1.0
       V7.0
			

(See /phtapert.pro)


PHTAPERTURES

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	PHTAPERTURES

 PURPOSE:
	Definition of the common block APERTURE_SIZE for inclusion into
	other routines. This common block stores data about the phot aperture
 	diameters (mm, arcsec, steradians) and shapes. 

 CATEGORY:
       PIA - common block

 CALLING SEQUENCE:
	@phtapertures

 COMMON BLOCK PARAMETERS
         P_MM : PHT-P aperture dimensions in mm
	  P_AS : PHT-P aperture dimensions in arcseconds
	  P_SR : PHT-P aperture dimensions in steradians
         P_Shape : PHT-P aperture shapes

	  C1_MM : PHT-C100 (square) pixel size in mm
	  C1_AS : PHT-C100 (square) pixel size in arcseconds
	  C1_SR : PHT-C100 (square) pixel size in steradians

	  C2_MM : PHT-C200 (square) pixel size in mm
	  C2_AS : PHT-C200 (square) pixel size in arcseconds
	  C2_SR : PHT-C200 (square) pixel size in steradians 

 MODIFICATION HISTORY:
 	Written by: Huw Morris (DRAL), February 1995
	Oct 95 Version 3.5
			

(See /phtapertures.pro)


PHTBCKDEF

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	PHTBCKDEF
 PURPOSE:
	This is not an IDL routine as such, but contains the definition of the
	common block PHTBCKDEF for inclusion into other routines. By defining
       the common block in one place, the problem of conflicting definitions
       is avoided. It contains, also, the values of the default backgrond 
       which can be considered in order to perform the point source extraction. 

	This file is included into routines that need this common block and the 
       value default background with the single line (left justified)

				  @phtbckdef



	This file  contains the following variables:

	EXP_H_X : The default expected value of h_x as defined in PIA_SM_PSEX
       EXP_H_Y : The default expected value of h_y as defined in PIA_SM_PSEX
       EXP_H_C : The default expected value of h_c as defined in PIA_SM_PSEX
       DEF_SIGMA_H_X: The standard variation of h_x as defined in PIA_SM_PSEX
       DEF_SIGMA_H_Y: The standard variation of h_y as defined in PIA_SM_PSEX 
       DEF_SIGMA_H_C: The standard variation of h_c as defined in PIA_SM_PSEX 
       FACTOR = The factor which indicates haw many times the quantities H 
                should be greater than the EXP_H

 MODIFICATION HISTORY:
	Paola Merluzzi                          August 1995

(See /phtbckdef.pro)


PHTCAP

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	PHTCAP

 PURPOSE:
	Definition of the common block PHTCAP for inclusion into other routines.  By defining
	The common block PHTCAP contains information about the CRE integration
	capacitances.

 CATEGORY:
       PIA - common block

 CALLING SEQUENCE:
	@phtcap

 COMMON BLOCK PARAMETERS:
	P1CAP : The P1 detector capacitance
	P2CAP : The P2 detector capacitance
	P3CAP : The P3 detector capacitance
	C1CAP : The C100 capacitance
	C2CAP : The C200 capacitance
	SLCAP : The SL capacitance 
	SSCAP : The SS capacitance 

 MODIFICATION HISTORY:
	Wrtten by: Carlos GABRIEL(ESA/ESTEC) 	October 1994
       Modified (last) by:  cg			April 1995
	Oct 95 Version 3.5

(See /phtcap.pro)


PHTCAP_INIT

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       Phtcap_init

 PURPOSE:
       Initializes the common block PHTCAP 

 CATEGORY:
          PIA - initialization

 CALLING SEQUENCE:
       PHTCAP_INIT

 COMMON BLOCKS:
	phtcap

 MODIFICATION HISTORY:
	Written by: Carlos GABRIEL(ESA/ESTEC) 	October 1994
       Modified (last) by:  cg			April 1995
	Oct 95 Version 3.5
	November 95 (new values acc to cal U)	November 1995
	

(See /phtcap_init.pro)


PHTCHOPCOR

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       PHTCHOPCOR

 PURPOSE:
       Define the common block CHOPCOR, containing the correction factors for
	chopped measurements.
        CHOPCORR_STR = {chop_dsg, inchop_time, p1chopcor p2chopcor,   $
                        p3chopcor, c1chopcor, c2chopcor, slchopcor}

 CATEGORY:
       PIA - common block

 CALLING SEQUENCE:
       @phtchopcor

 OUTPUT PARAMETERS:
        

 MODIFICATION HISTORY:
       Written by: J. Acosta                           NOVEMBER 1997
       Version 6.6

(See /phtchopcor.pro)


PHTCLA

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	PHTCLA

 PURPOSE:
	Definition of the common block PHTCLA (PHT CAL-A data) for inclusion 
	into other routines. 

 CATEGORY:
       PIA - common block

 CALLING SEQUENCE:
	@phtcla


 MODIFICATION HISTORY:
	Wrtten by: Carlos GABRIEL(ESA/ESTEC) 
	cla_first_handle, cla_last_handle added (WMT)	May 1996
	Oct 95 Version 3.5

(See /phtcla.pro)


PHTCLA_INIT

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       Phtcla_init
 PURPOSE:
       Initializes the structure PHTCLA defining the contents as
	a template structure PHTCLA_TYPE. It can be used for clearing
	the whole CLA structure, in case this should show as necessary. 

 CATEGORY:
       PIA - initialization

 CALLING SEQUENCE:
       @phtcla_init

 COMMON BLOCKS:
	phtcla

 MODIFICATION HISTORY:
	Wrtten by: Carlos GABRIEL(ESA/ESTEC) 	July 1994
       Modified (last) by:  cg			September 1995
	cla_first_handle and cla_last_handle added (WMT) May 1996
	Oct 95 Version 3.5
	

(See /phtcla_init.pro)


PHTCRELIN

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	PHTCRELIN

 PURPOSE:
	Definition of the common block PHTCRELIN for inclusion into other
	routines.  The common block PHTCRELIN contains the CRE linerization
	correction for the PHT detectors.

 CATEGORY:
       PIA - common block

 CALLING SEQUENCE:
	@phtcrelin

 COMMON BLOCK PARAMETERS:
	PC1CRELIN : The C100 linearisation corrections
	PC2CRELIN : The C200 linearisation corrections
	PPCRELIN : The P1, P2, P3 linearisation corrections

 MODIFICATION HISTORY:
	Wrtten by: Carlos GABRIEL, ESA/ESTEC 		March 1995
	Oct 95 Version 3.5

(See /phtcrelin.pro)


PHTCS

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	PHTCS

 PURPOSE:
	Definition of the common block PHTCS (Compact Status) for inclusion
	into other routines.

 
 CALLING SEQUENCE:
	@phtcs

 CATEGORY:
          PIA - common block

 COMMON BLOCK PARAMETERS:
		CSUNIT	   = Index of the units in the block
		PSTAUNIT   = String corresponding to the 8 numbers identifying 
			     the PHT CS (e.g. '12345604' for PSTA12345604.FITS) 
		PSTADIMS   = Actual dimension of the keywords corresponding to 
			     the CSUNIT
               All Compact Status Keywords CSGPXXXX as PSTAXXXX
               All other Compact Status Keywords as in the archive 

 MODIFICATION HISTORY:
	Written by: Carlos GABRIEL, Dec 1993
	Oct 95 Version 3.5

(See /phtcs.pro)


PHTCS_GET_REC

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	PHTCS_GET_REC

 PURPOSE:
	Extract a compact status (cs) record using the PHTCS structure

 CATEGORY:
       PIA - initialization

 CALLING SEQUENCE:
	phtcs_get_rec

 COMMON BLOCKS:
	phtcs

 RESTRICTIONS:
	This file should be used after reading the startup file for various
       common blocks: @phtcs_init

 PROCEDURE:
	PHTCS contains the following field definitions:

		UNIT   = String corresponding to the 6 numbers identifying 
			     the PHT CS (e.g. '123456' for PSTA123456.FITS) 
		DIMS   = Actual dimension of the keywords corresponding to 
			     the CSUNIT
               All Compact Status Keywords CSGPXXXX as PSTAXXXX
               All other Compact Status Keywords as in the archive 

 MODIFICATION HISTORY:
       Wrtten by: Wai-Ming Tai (DIAS), July 1994
	Oct 95 Version 3.5
			

(See /phtcs_get_rec.pro)


PHTCS_INIT

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	PHTCS_INIT

 PURPOSE:
	Definition of the PHTCS structure for inclusion into other routines.  

 CATEGORY:
       PIA - initialization

 CALLING SEQUENCE:
	@phtcs_init

 PROCEDURE:
	PHTCS contains the following field definitions:

		UNIT   = String corresponding to the 6 numbers identifying 
			     the PHT CS (e.g. '123456' for PSTA123456.FITS) 
		DIMS   = Actual dimension of the keywords corresponding to 
			     the CSUNIT
               All Compact Status Keywords CSGPXXXX as PSTAXXXX
               All other Compact Status Keywords as in the archive 

 MODIFICATION HISTORY:
	Written by: Carlos GABRIEL (ESA/ESTEC)		 Dec 1993
       Modified by: wmt				 July 1994
	Oct 95 Version 3.5
	Dummy structure deleted (CG)			November 1995
			

(See /phtcs_init.pro)


PHTDARKCUR

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	PHTDARKCUR

 PURPOSE:
	Define the common block DARKCUR, containing the PHT dark currents.

 CATEGORY:
       PIA - common block

 CALLING SEQUENCE:
	@darkcur

 OUTPUT PARAMETERS:
       DARKCURHDR -- CONTAIN THE FITS HEADER OF THE DARKCURRENT FILE

 MODIFICATION HISTORY:
	Written by: W. M. TAI (DIAS)                  	OCT 1994
	Oct 95 Version 3.5

(See /phtdarkcur.pro)


PHTDARKORB

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	PHTDARKORB

 PURPOSE:
	Define the common block DARKORB, containing the PHT dark currents.

 CATEGORY:
       PIA - common block

 CALLING SEQUENCE:
	@phtdarkorb


 MODIFICATION HISTORY:
	Written by: J. Acosta                  			NOVEMBER 1997
	Version 6.6
	Extension for DARKPROAOT  (CG)				January 1998
	V7.0
	Extension for SLDARKTIME+DARKTDEP (JAc)			August 1998
	V7.2

(See /phtdarkorb.pro)


PHTDIETRANS

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	PHTDIETRANS

 PURPOSE:
	Definition of the common block PHTDIETRANS (Digital Interface
	Electronics (DIE) transfer function for inclusion into other routines.

 CATEGORY:
       PIA - common block

 CALLING SEQUENCE:
	@phtdietrans

 COMMON BLOCK PARAMETERS:
	PHTDIETRANS contains the following arrays (2 * 3 dimensions, 
		    corresponding to the DIE Units 1 or 2, and to the 
		    three possible selected gains in the order 1, 8 and 40) :

	  PDIEFIX	= Fixed Offsets                      
	  PDIEUOF	= Offsets Dependent on signal gain   
	  PDIEGN1	= Signal Gains                       
	  PDIEGN2	= Offset Gains                       

 MODIFICATION HISTORY:
	Written by: Carlos GABRIEL (ESA/ESTEC) 		 Jan 1994
	Oct 95 Version 3.5

(See /phtdietrans.pro)


PHTDYNCAL

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	PHTDYNCAL

 PURPOSE:
	Definition of the common block PHTDYNCAL (Dynamical calibration
	 structure) for inclusion into other routines.  

 CATEGORY:
       PIA - common block

 CALLING SEQUENCE:
	@phtdyncalib

 MODIFICATION HISTORY:
 	Written by:	Jose Acosta (ISO SOC - VILSPA)  	May 1998
	dyncalib_first_handle, dyncalib_last_handle and phtdyncalib_desc added
	Version 7.1
			

(See /phtdyncal.pro)


PHTERD

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	PHTERD

 PURPOSE:
	Definition of the common block PHTERD (Edited Raw Data) for inclusion
	into other routines.

 CATEGORY:
       PIA - common block

 CALLING SEQUENCE:
	@phterd


 MODIFICATION HISTORY:
 	Written by:	Carlos Gabriel (ESA/ESTEC)
	erd_first_handle, erd_last_handle added (WMT)	May 1996
	PHTERD_DESC added	(WMt)			May 1996
	Oct 95 Version 3.5

(See /phterd.pro)


PHTERD_INIT

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       Phterd_init

 PURPOSE:
       Initializes the structure PHTERD defining the contents as
	a template structure PHTERD_TYPE. It can be used for clearing
	the whole ERD structure, in case this should show as necessary. 

 CALLING SEQUENCE:
       @phterd_init


 COMMON BLOCKS:
	phterd

 MODIFICATION HISTORY:
       Written by: C. Gabriel                      	January 1994
	Modified last by: CG, Wai-Ming Tai		September 1994
	Oct 95 Version 3.5
	PHTERD descriptor fixed - CG			February 1997
	

(See /phterd_init.pro)


PHTFCS

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	PHTFCS

 PURPOSE:
	Definition of the common block PHTFCS (Fine Calibration Source power
	tables) for inclusion into other routines.  

 CATEGORY:
       PIA - common block

 CALLING SEQUENCE:
	@phtfcs

 COMMON BLOCK PARAMETERS:
	P1FCSPOW : The P1 FCS power table
	P2FCSPOW : The P2 FCS power table
	P3FCSPOW : The P3 FCS power table
	C1FCSPOW : The C100 FCS power table
	C2FCSPOW : The C200 FCS power table

 MODIFICATION HISTORY:
	Wrtten by: Carlos GABRIEL, ESA/ESTEC 		October 1994
	Oct 95 Version 3.5
	Common extended with with validity limits (CG)	January 1998
	V7.0 
			

(See /phtfcs.pro)


PHTFFIELD

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	PHTFFIELD

 PURPOSE:
	Definition of the common block PHTFFIELD (External Flat Field
	Factors) for inclusion into other routines.  

 CATEGORY:
       PIA - common block

 CALLING SEQUENCE:
	@phtffield

 COMMON BLOCK PARAMETERS:
	This file stores the external flat field factors

	PHTFFIELD contains the following variables:

	C1FLATF : The C100 Flatfield factors
	C1FLATU : Uncertainties of C1FLATF
	C2FLATF : The C200 Flatfield factors
	C2FLATU : Uncertainties of C2FLATF


 MODIFICATION HISTORY:
	Written by: Carlos GABRIEL, ESA/ESTEC 		May 1997
	V6.3
			

(See /phtffield.pro)


PHTFILTER

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	PHTFILTER

 PURPOSE:
	Definition of the common block PHTFILTER (PHT filter mnemonics) for 
	inclusion into other routines.

 CATEGORY:
       PIA - common block

 CALLING SEQUENCE:
	@phtfilter

COMMON BLOCK PARAMETERS:
	This common block contains string arrays for all PHT filters

	P1FILTERS           ; P1
	P2FILTERS           ; P2
	P3FILTERS           ; P3
	C1FILTERS           ; C100
	C2FILTERS           ; C200

  Modification History:
	Wrtten by: Carlos GABRIEL (ESA/ESTEC-SAI)	March 1995
	Oct 95 Version 3.5
			

(See /phtfilter.pro)


PHTFILTER_INIT

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       PHTFILTER_INIT
 PURPOSE:
       Initializes the PHTFILTER (PHT filter mnemonics) common block.

 CATEGORY:
       PIA - initialization

 CALLING SEQUENCE:
       PHTFILTER_INIT

 COMMON BLOCKS:
	phtfilter

 MODIFICATION HISTORY:
       Written by: Carlos GABRIEL (ESA/ESTEC-SAI)          March 1995
	Oct 95 Version 3.5
	Blanks removed from C100 filter IDs (CG)	    February 1996
			

(See /phtfilter_init.pro)


PHTFILTER_PROP

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	PHTFILTER_PROP

 PURPOSE:
	Definition of the common block PHTFILTER_PROP for inclusion into routines.
	The common block PHTFILTER_PROP contains the main filter properties.

 CATEGORY:
       PIA - common block

 CALLING SEQUENCE:
	@phtfilter_prop

 COMMON BLOCK PARAMETERS:
	filtprop: Structure containing central wavelengths and airy disks per
		detector (filtprop.p1airyd, filtprop.p1cwl = arrays per filter 
		arranged according to PHTFILTER)

 MODIFICATION HISTORY:
	Written by: Carlos GABRIEL(ESA/VILSPA-SAI) 	June 1996
	Ingolf Heinrichsen
	Split routine into init and common		Jan 1997

(See /phtfilter_prop.pro)


PHTFILTER_PROP_INIT

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	PHTFILTER_PROP_INIT

 PURPOSE:
	Initialization of the common block FILTPROP for inclusion into 
	routines. The reference wavelengths are read from the PFLUXCONV.FITS
	calibration file. The airy disk diameters are hard-coded
	The common block is defined in PHTFILTER_PROP and contains the main 
	filter properties.

 CATEGORY:
       PIA - initialisation

 CALLING SEQUENCE:
	phtfilter_prop_init

 COMMON BLOCKS:
	phtfilter_prop

 SIDE EFFECTS:
	The values in the  FILTPROP common block are initialised

 COMMON BLOCK PARAMETERS:
	filtprop: Structure containing central wavelengths and airy disks per
		detector (filtprop.p1airyd, filtprop.p1cwl = arrays per filter 
		arranged according to PHTFILTER)

 PROCEDURES USED:
       ASTRO LIB: fxhread


 MODIFICATION HISTORY:
	Written by: Ingolf Heinrichsen			Jan  1997
		    (Split init and common definition)

(See /phtfilter_prop_init.pro)


PHTFPSF

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	PHTFPSF

 PURPOSE:
	Definition of the common block PHTFPSF (Single pixel fpsf factors)
	for inclusion into other routines.  

 CATEGORY:
       PIA - common block

 CALLING SEQUENCE:
	@phtfpsf

 COMMON BLOCK PARAMETERS:
	This file stores the single pixel fpsf factors

	PHTFPSF contains the following variables:

	phtfpsf: Structure containing
			cpsf: central fpsf values
			lpsf: lateral fpsf  [f(46)-C100, f(92)-C200]
			dpsf: diagonal fpsf [f(46SQRT2)-C100, f(92SQRT2)-C200] 


 MODIFICATION HISTORY:
	Written by: Carlos GABRIEL, ESA/VILSPA 		June 1999
	V7.4
			

(See /phtfpsf.pro)


PHTFPSF_INIT

[Previous Routine] [Next Routine] [List of Routines]
  Name:
	PHTfpsf_init

  Purpose:
	Initialises the phtfpsf common block

 CATEGORY:
      	PIA - initialization

 CALLING SEQUENCE:
	PHTFPSF

 COMMON BLOCKS:
	phtfpsf

 MODIFICATION HISTORY:
 	Written by:	C. Gabriel (ESA/VILSPA)		June 1999
	V7.4

(See /phtfpsf_init.pro)


PHTFTOF

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	PHTFTOF

 PURPOSE:
	Definition of the common block PHTFTOF (External Filter to filter
	Factors) for inclusion into other routines.  

 CATEGORY:
       PIA - common block

 CALLING SEQUENCE:
	@phtftof

 COMMON BLOCK PARAMETERS:
	This file stores the external filter to filter factors

	PHTFTOF contains the following variables:

	PPFTOF : The P1, P2, P3 filter to filter corrections and uncertainties


 MODIFICATION HISTORY:
	Written by: Carlos GABRIEL, ESA/VILSPA 		April 1999
	V7.4
			

(See /phtftof.pro)


PHTHK

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	phthk

 PURPOSE:
	Definition of the common block PHTHK (PHT house Keeping) for
	inclusion into other routines.  

 CATEGORY:
          PIA - common block

 CALLING SEQUENCE:
	@phthk

COMMON BLOCK PARAMETERS:
	PHTCS contains the following arrays:

		hkout   :converted hk data, reduced to specific measurement
                        with get_pht_hk
               idb     :database array,idb(1,i)contains the name of the
                        hk with index i in hkout.
                        For more information see the conv_hk program
               hkdat   :pht data from the GEHK file
               timestep:timestep, after use of get_pht_hk reduced and converted
               hdr_idb :header of the idb-table

 MODIFICATION HISTORY:
       Written by: Andreas Karch, October 1994
	Oct 95 Version 3.5
			

(See /phthk.pro)


PHTILLUM

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	PHTILLUM

 PURPOSE:
	Definition of the common block PHTILLUM (Fine Clibration Soure
	Illumination matrices) for inclusion into other routines.  

 CATEGORY:
       PIA - common block

 CALLING SEQUENCE:
	@phtillum

 COMMON BLOCK PARAMETERS:
	This file stores the FCS illumination matrices 

	PHTILLUM contains the following variables:

	C1ILCOR : The C100 FCS illumination matrices
	C1ILLUN : Uncertainties of C1ILCOR
	C2ILCOR : The C200 FCS illumination matrices
	C2ILLUN : Uncertainties of C2ILCOR


 MODIFICATION HISTORY:
	Written by: Carlos GABRIEL, ESA/ESTEC 		November 1994
	Oct 95 Version 3.5
			

(See /phtillum.pro)


PHTINTT_CORR_INIT

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       PHTINTT_CORR_INIT

 PURPOSE:
	Initialise a common block containing the reset interval correction
	factors

 CATEGORY:
	PIA - I/O

 CALLING SEQUENCE:
       PHTINTT_CORR_INIT [,ERROR=error]

 INPUT:
       (none)

 KEYWORD:
	DATA: 'FITS' or none for FITS files, 'ASCII' for 'cresint.txt'
	ERROR : 0 if OK, 1 if source file not found

 RESTRICTIONS:
	FITS files with official names (eg 'PP1RESETI') or 'cresint.txt' must
	reside in the !CALG directory, otherwise program ends with error=1

 PROCEDURES USED: 
       Common Block(s) or @ procedure(s):
        phtintt_corr       

 MODIFICATION HISTORY:
       Written by: C. Gabriel  (ESA-SAI)		May 1997
	V6.3
	new column added (dS/dA0) (CG)
	and reading from FITS file			September 1997
	V6.5

(See /phtintt_corr_init.pro)


PHTOMEGA

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	PHTOMEGA

 PURPOSE:
	Definition of the common block PHTOMEGA for inclusion into
	other routines. This common block stores data about the phot
	solid angles of pixels and aperture, as well as their apparent
	sizes on the sky and relative off-sets. 

 CATEGORY:
       PIA - common block

 CALLING SEQUENCE:
	@phtomega

 COMMON BLOCK PARAMETERS

         C100-detector:

         C1OFFY:   fltarr(9,7,2), fltarr(pixel,filter,value/uncertainty)
                   Offset(") in y relative to centre of array
         C1OFFZ:   fltarr(9,7,2), fltarr(pixel,filter,value/uncertainty)
                   Offset(") in z relative to centre of array
         C1SIZEY:  fltarr(9,7,2), fltarr(pixel,filter,value/uncertainty)
                   Aperture dimension y (");         
         C1SIZEZ:  fltarr(9,7,2), fltarr(pixel,filter,value/uncertainty)
                   Aperture dimension z ("); 
         C1OM:     fltarr(9,7,2), fltarr(pixel,filter,value/uncertainty)
                   Omega (sr)

         C200-detector:

         C2OFFY:   fltarr(4,5,2), fltarr(pixel,filter,value/uncertainty)
                   Offset(") in y relative to centre of array
         C2OFFZ:   fltarr(4,5,2), fltarr(pixel,filter,value/uncertainty)
                   Offset(") in z relative to centre of array
         C2SIZEY:  fltarr(4,5,2), fltarr(pixel,filter,value/uncertainty)
                   Aperture dimension y (");         
         C2SIZEZ:  fltarr(4,5,2), fltarr(pixel,filter,value/uncertainty)
                   Aperture dimension z ("); 
         C2OM:     fltarr(4,5,2), fltarr(pixel,filter,value/uncertainty)
                   Omega (sr)
         
         P-detectors:

         PSIZEY:   fltarr(14,14,2), fltarr(aperture, filter, value/uncertainty)
                   Aperture diameter (") in Y'

         PSIZEZ:   fltarr(14,14,2), fltarr(aperture, filter, value/uncertainty)
                   Aperture diameter (") in Z'

         POM:      fltarr(14,14,2), fltarr(aperture, filter, value/uncertainty)
                   Omega (sr)

 MODIFICATION HISTORY:
 	Written by: Ingolf Heinrichsen
       Jan 98 Version 1.0
       V7.0
			

(See /phtomega.pro)


PHTOPTPOW

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	PHTOPTPOW

 PURPOSE:
	Definition and initialization of the common block PHTOPTPOW (Fine
	Calibration Source illumo=ination power levels) for inclusion into
	other routines.  

 CATEGORY:
          PIA - initialization
          PIA - common block

 CALLING SEQUENCE:
	@phtoptpow

 COMMON BLOCK PARAMETERS:
	This file stores the optical power data as used for
	the production of the PHT FCS power tables

	PHTOPTPOW contains the following variables:

	LONGPOW :  The opt power values corresponding to the P detectors
	SHORTPOW : The opt power values corresponding to the C detectors

 COMMON BLOCKS:
	optpow

 MODIFICATION HISTORY:
	Written by: Carlos GABRIEL, ESA/ESTEC 			October 1994
       Modified (last) by: CG   				April 1995
	Oct 95 Version 3.5

(See /phtoptpow.pro)


PHTPOLAR

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	PHTPOLAR

 PURPOSE:
	Definition of the common block PHTPOLAR (polarizer mnemonics) for 
	inclusion into other routines. 

 CATEGORY:
       PIA - common block

 CALLING SEQUENCE:
	@phtpolar

COMMON BLOCK PARAMETERS:
	This common block contains string arrays for all PHT POLARIZERS

	PHTPOLAR            

  Modification History:
	Written by: Carlos GABRIEL (ESA/VILSPA-SAI)	February 1996

(See /phtpolar.pro)


PHTPPSF

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	PHTPPSF

 PURPOSE:
	Definition of the common block PHTPPSF Point Spread Function Factors) 
	for inclusion into other routines. 

 CATEGORY:
        PIA - common block

 CALLING SEQUENCE:
	@phtppsf

 COMMON BLOCK PARAMETERS:
	This file stores data about the phot apertures

	  PHTPPSF : Flt Array(16,14) - Point Spread Function for 
					PHT-P             (0-13,0-13) FIL-APER
	                                PHT-C  PSF_ARRAY  (14  ,0-13)    -FIL 
	                                PHT-C  PSF_PIXEL  (15  ,0-13)    -FIL 

 MODIFICATION HISTORY:
	Wrtten by: Carlos GABRIEL (ESA/ESTEC-SAI) 	March 1995
	Oct 95 Version 3.5
	No change in the CB but in its definition (16,14) instead of (15,14)
	V7.4    Jun 1999
			

(See /phtppsf.pro)


PHTRESACT

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	PHTRESACT

 PURPOSE:
	Definition of the common block PHTRESACT (Actual Detector 
	Responsivities and Uncertainties) for inclusion into other routines.

 CATEGORY:
       PIA - common block

 CALLING SEQUENCE:
	@phtresact

 COMMON BLOCK PARAMETERS:
	This file stores data corresponding to (calculated) PHT responses

	PHTRESACT contains the following variables:

	P1RESPACT : The P1 detector response
	P1RESPUNC : Uncertainty of P1RESPACT
	P2RESPACT : The P2 detector response
	P2RESPUNC : Uncertainty of P2RESPACT
	P3RESPACT : The P3 detector response
	P3RESPUNC : Uncertainty of P3RESPACT
	C1RESPACT : Array: The C100 9 pixel responses
	C1RESPUNC : Uncertainties of C1RESPACT
	C2RESPACT : Array: The C200 4 pixel responses
	C2RESPUNC : Uncertainties of C2RESPACT
	SLRESPACT : Array: The S 128 pixel responses 
	SLRESPUNC : Uncertainties of SLRESPACT

 MODIFICATION HISTORY:
	Written by: Carlos GABRIEL, ESA/ESTEC 		October 1994
	Oct 95 Version 3.5
	Extended with origin measurements names and filters (CG)  Jul 97
	V6.4
			

(See /phtresact.pro)


PHTRESDEF

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	PHTRESDEF
 PURPOSE:
	Definition of the common block PHTRESDEF (Default Detector
	Responsivities) for inclusion into other routines.  

 CATEGORY:
       PIA - common block

 CALLING SEQUENCE:
	@phtresdef

 COMMON BLOCK PARAMETERS:
	This file stores data from a PHT response file

	PHTRESP contains the following variables:

	P1RESP : The P1 detector response
	P2RESP : The P2 detector response
	P3RESP : The P3 detector response
	C1RESP : Array: The C100 9 pixel responses
	C2RESP : Array: The C200 4 pixel responses
	SLRESP : Array: The S 128 pixel responses 
	P1RESU : Uncertainty of P1RESP 
	P2RESU : Uncertainty of P2RESP 
	P3RESU : Uncertainty of P3RESP 
	C1RESU : Uncertainties of C1RESP 
	C2RESU : Uncertainties of C2RESP
	SLRESU : Uncertainties of SLRESP

 MODIFICATION HISTORY:
	Written by: Carlos GABRIEL, ESA/ESTEC 		October 1994
	Modified (last) by: CG				November 1994
	Oct 95 Version 3.5
			

(See /phtresdef.pro)


PHTRESPORB

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	PHTRESPORB

 PURPOSE:
	Define the common block RESPORB, containing the PHT default 
	responsivities.

 CATEGORY:
       PIA - common block

 CALLING SEQUENCE:
	@phtresporb


 MODIFICATION HISTORY:
	Written by:  Carlos GABRIEL (ESA-VILSPA/SAI)		January 1998
	V7.0

(See /phtresporb.pro)


PHTSCP

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	PHTSCP

 PURPOSE:
	Definition of the common block PHTSCP (Signals per Chopper Plateau) 
	for inclusion into other routines.  

 CATEGORY:
       PIA - common block

 CALLING SEQUENCE:
	@phtscp

 MODIFICATION HISTORY:
 	Written by:	Carlos Gabriel (ESA/ESTEC)
	scp_first_handle, scp_last_handle and phtscp_desc added
		(WMT)			May 1996
	Oct 95 Version 3.5
			

(See /phtscp.pro)


PHTSCP_INIT

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       PhtScp_init

 PURPOSE:
       Initializes the structure PHTSCP (Signals per Chopper Plateau) 
	defining the contents as a template structure PHTSCP_TYPE. 
	It can be used for clearing the whole SCP structure, in case 
	this should show as necessary. 

 CATEGORY:
       PIA - initialization

 CALLING SEQUENCE:
       @phtscp_init

 COMMON BLOCKS:
	phtscp

 MODIFICATION HISTORY:
       Written by: C. Gabriel (ESA/ESTEC)                September 1994
	Oct 95 Version 3.5
	Extension for ANDR,AVSD and ARSI (CG)		  January 1996
			

(See /phtscp_init.pro)


PHTSELNDR

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	PHTSELNDR

 PURPOSE:
	Definition of the common block PHTSELNDR (Non-destructive Read-out
	Selection) for inclusion into other routines.  

 CATEGORY:
       PIA - common block

 CALLING SEQUENCE:

	@phtselndr

 COMMON BLOCK PARAMETERS:
	PHTSELNDR contains the following variables:

	PP1SNDR: Array of NDRs skipped by P1 integration ramps per Tint 
	PP2SNDR: Array of NDRs skipped by P2 integration ramps per Tint 
	PP3SNDR: Array of NDRs skipped by P3 integration ramps per Tint 
	PC1SNDR: Array of NDRs skipped by C1 integration ramps per Tint 
	PC2SNDR: Array of NDRs skipped by C2 integration ramps per Tint 
	PSSSNDR: Array of NDRs skipped by SS integration ramps per Tint 
	PSSSNDR: Array of NDRs skipped by SL integration ramps per Tint 

 MODIFICATION HISTORY:
	Carlos GABRIEL, ESA/ESTEC 		February 1995
	Oct 95 Version 3.5

(See /phtselndr.pro)


PHTSLWAVLEN

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	PHTSLWAVLEN
 PURPOSE:
	Definition of the common block PHTSLWAVLEN (PHT-S Wavelength 
	Calibration) for inclusion into other routines.  

 CATEGORY:
       PIA - common block

 CALLING SEQUENCE:
	@phtslwavlen

 COMMON BLOCK PARAMETERS:
	This file stores the wavelengths of the ISOPHT SS and SL detectors

	PHTSLWAVLEN contains the following variables:

	SLWAVELEN : The SS and SL wavelenghts

 MODIFICATION HISTORY:
	Written by: Carlos GABRIEL, ESA/ESTEC 		October 1994
	Oct 95 Version 3.5

(See /phtslwavlen.pro)


PHTSPD

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	PHTSPD

 PURPOSE:
	Definition of the common block PHTSPD (Standard Processed Data) for
	inclusion into other routines.  

 CATEGORY:
       PIA - common block

 CALLING SEQUENCE:
	@phtspd


 MODIFICATION HISTORY:
 	Written by:	Carlos Gabriel (ESA/ESTEC)
	Oct 95 Version 3.5
			

(See /phtspd.pro)


PHTSPD_INIT

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       Phtspd_init

 PURPOSE:
       Initializes the structure PHTSPD (Standard Processed Data) defining
	the contents as a template structure PHTSPD_TYPE. It can be 
	used for clearing the whole SPD structure, in case this
	should show as necessary. 

 CATEGORY:
       PIA - initialization
 COMMON BLOCKS:
	phtspd

 CALLING SEQUENCE:
       @phtspd_init

 MODIFICATION HISTORY:
       Written by: C. Gabriel (ESA/ESTEC)              July 1994
	Mdodified (last) by: CG 			October 1994
	spd_first_handle, spd_last_handle added (WMT)   May 1996
	phtspd_desc added (WMT)				May 1996
	Oct 95 Version 3.5

(See /phtspd_init.pro)


PHTSRD

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	PHTSRD

 PURPOSE:
	Definition of the common block PHTSRD (Signal Data) for inclusion
 	into other routines.  

 CATEGORY:
       PIA - common block

 CALLING SEQUENCE:
	@phtsrd

 MODIFICATION HISTORY:
	Written by: Carlos Gabriel (ESA/ESTEC)
	srd_first_handle, srd_last_handle, phtsrd_desc added
	  (WMT)			May 1996
	Oct 95 Version 3.5
			

(See /phtsrd.pro)


PHTSRD_INIT

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       PhtSrd_init
 PURPOSE:
       Initializes the structure PHTSRD (Signal Data) defining the
	contents as a template structure PHTSRD_TYPE. It can be used
	for clearing the whole SRD structure, in case this should 
	show as necessary. 

 CATEGORY:
       PIA - initialization

 CALLING SEQUENCE:
       @phtsrd_init

 COMMON BLOCKS:
	phtsrd

 MODIFICATION HISTORY:
       Written by: C. Gabriel (ESA/ESTEC)             		July 1994
	Modified (last) by CG 					September 1994
	Oct 95 Version 3.5
	Extension: effective reset time and read-outs used (CG)	January 1996
			

(See /phtsrd_init.pro)


PHTVIGNET

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	PHTVIGNET

 PURPOSE:
	Definition of the common block VIGNET_TABLES (Chopper amplitude
	dependent vignetting tables) for inclusion into other routines.  

 CATEGORY:
       PIA - common block

 CALLING SEQUENCE:
	@phtvignet

 COMMON BLOCK PARAMETERS:
	This common block holds the tables for the chopper-amplitude-dependant
	vignetting.

	PP1Vign             ; P1
	PP2Vign             ; P2
	PP3Vign             ; P3

	PC1Vign	            ; C100
	PC2Vign             ; C200

	There is no vignetting done for PHT-S

 MODIFICATION HISTORY:
 	Written by:	Huw Morris (DRAL)		October 1994
	Oct 95 Version 3.5
			

(See /phtvignet.pro)


PHTW2JY

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	PHTW2JY

 PURPOSE:
	Definition of the common block PHTW2JY for inclusion into routines.
	The common block PHTW2JY contains the conversion factors needed for
	flux density and brightnes density extractions from in-band powers.

 CATEGORY:
       PIA - common block

 CALLING SEQUENCE:
	@phtw2jy

 COMMON BLOCK PARAMETERS:
	W2JY_P:	Conversion factors (W->Jy) for P1, P2, P3 (per filter)
	W2JY_C: Conversion factors (W->Jy) for C100, C200 (per filter)	
	V2JY_S: Conversion factors for PHT-S (Amperes->Jy) (per PHT-S pixel)
		(this are the calibrated factors) containing the A to 
		Jy calibration.  
	W2JY_S: Conversion factors for PHT-S (W->Jy)
	W2MJY_S: Conversion factors for PHT-S (W->MJy/sr)
	

 MODIFICATION HISTORY:
	Written by: Carlos GABRIEL(ESA/VILSPA-SAI) 		March 1996
	Changed (last) by CG - common extended for v2my		January 1997
	V6.0

(See /phtw2jy.pro)


PHTW2JY_INIT

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	PHTW2JY_INIT

 PURPOSE:
	Initialize the common block PHTW2JY for inclusion into routines.
	The common block PHTW2JY contains the conversion factors needed for
	flux density and brightnes density extractions from in-band powers.

 CATEGORY:
       PIA - initialization

 CALLING SEQUENCE:
	phtw2jy_init

 COMMON BLOCK PARAMETERS:
	W2JY_P:	Conversion factors (W->Jy) for P1, P2, P3 (per filter)
	W2JY_C: Conversion factors (W->Jy) for C100, C200 (per filter)	
	V2JY_S: Conversion factors for PHT-S (Amperes->Jy) (per PHT-S pixel)
		(this are the calibrated factors) containing the A to 
		Jy calibration.  
	W2JY_S: Conversion factors for PHT-S (W->Jy)
	W2MJY_S: Conversion factors for PHT-S (W->MJy/sr)
	

 MODIFICATION HISTORY:
	Written by: Carlos GABRIEL(ESA/VILSPA-SAI) 	April 1996
	Bug for PHT-S extended sources fixed by new
	calibration files fixed (CG)			March 1997	

(See /phtw2jy_init.pro)


PHT_S

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	PHT_S

 PURPOSE:
	This is not an IDL routine as such, but contains the definition of the
	common block PHT_S for inclusion into other routines.  By 
	defining the common block in one place, the problem of conflicting 
	definitions is avoided.

	This file is included into routines that need this common block with
	the single line (left justified)

				  @pht_s


	This file stores data about PHT-S detector responses

	PHT_S contains the following variables:

	  S_PSF : Point spread function (array)
	  S_WaveL : Centre wavelengths for each pixel (array)
	  S_Ratio : Relative detector response at the central wavelength (array)
	  S_Trans : Transmission of the beam path (array)

	  DLambdaSS : Spectral bandwidth for PHT-SS
	  DLambdaSL : Spectral bandwidth for PHT-SL

	  Area : Primary mirror area in m^2

	  S_SR : Solid angle of the aperture in steradians

 CATEGORY:
          PIA - common block

 MODIFICATION HISTORY:
	Wrtten by: Huw Morris (DRAL), February 1995
	Oct 95 Version 3.5

(See /pht_s.pro)


PHT_S_INIT

[Previous Routine] [Next Routine] [List of Routines]
  Name:
	PHT_S_Init

  Purpose:
	Initialises the pht_s common block

 CATEGORY:
      	PIA - initialization

 CALLING SEQUENCE:
	PHT_S_INIT

 COMMON BLOCKS:
	pht_s

 MODIFICATION HISTORY:
 	Written by:	Huw Morris (DRAL), February 1995
	Oct 95 Version 3.5

(See /pht_s_init.pro)


PIA

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	PIA

 PURPOSE:
	This is the "ISOPHOT Interactive Analysis" main program
	to be called to start an Interactive Analysis session.
	Menues lead you through the capabilities of the tool.
	No other routines should be called directly from the command
	line.

 CATEGORY:
	PIA - graphics
	
 CALLING SEQUENCE:
	PIA
	
 COMMON BLOCKS:
	colour_indices
	phterd

 PROCEDURES USED:
	PIA LIB:
		cs_init
		erd_init
		pia_aalevel
		pia_buffil
		pia_cal_crelin
		pia_cal_darkcur
		pia_cal_dietran
		pia_cal_fcsill
		pia_cal_fcspow
		pia_cal_fpgc
		pia_cal_ndrsel
		pia_cal_ppsf
		pia_cal_respons
		pia_cal_swavl
		pia_cal_vignet
		pia_cal_colour_correction
		pia_extfil
		pia_fxtfil
		pia_intfil
		pia_prtdef
		pia_set_sysvar
		pia_view
		scp_init
		set_colours
		spd_init
		srd_init
       INTERNAL:
		pia_event

 MODIFICATION HISTORY:
 	Written by:	D. Skaley (MPIK)		August 94
       Modified (last) by:    CG			September 1997
	Responsivity check added in calibration  JAc    November 1997
	New (orb.pos.dep.) cal. menues added (CG)	February 1998
	Delete buffers only after question (CG)		December 1999
	Map simulator button added (CG)			March 2000
	V8.2	

(See /pia.pro)


PIACMN_GBLDEF

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	PIACMN_GBLDEF

 PURPOSE:
	Definition of common block PIACMN_GLBDEF
	for global default values.

 CATEGORY:
	PIA - common blocks

 CALLING SEQUENCE:
	@PIACMN_GBLDEF

 VARIABLES:
	gbldef	structure of:
		calgdir :	Directory for cal-G files
		datadir :	Directory for ISO data files
		workdir :	Working directory
		fitsext :	FITS file extension (usually .FITS)

 MODIFICATION HISTORY:
	Written by: D. Skaley
	Oct 95 Version 3.5

(See /piacmn_gbldef.pro)


PIACMN_POW2FB

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	PIACMN_POW2FB

 PURPOSE:
	Definition of common block PIACMN_POW2FB
	holds constants for the transformation from power to flux/brightness.

 CATEGORY:
	PIA - common block

 CALLING SEQUENCE:
	@PIACMN_POW2FB

 VARIABLES:
	ppsf		A 15 x 14 float array of PSF values.
	aper_m		Aperture values in m / m^2
	aper_r		Aperture values in rad / sr
	p_wavel		Central wavelengths of PHT-P filters [m]
	c_wavel		Central wavelengths of PHT-C filters [m]
	p_ratio		Response ratio of PHT-P filters [1/m]
	c_ratio		Response ratio of PHT-C filters [1/m]

 MODIFICATION HISTORY:
	Written by: D Skaley
	Oct 95 Version 3.5

(See /piacmn_pow2fb.pro)


PIA_ON_LINE

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       PIA_ON_LINE

 PURPOSE:
	Insert all the dynamical commons into some environment (e.g. within 
	the general IDL environment)

 CATEGORY:
	PIA - I/O

 CALLING SEQUENCE:
       @pia_on_line

 INPUT:

 RESTRICTIONS:
	(none)       

 PROCEDURES USED: 
       Common Block(s) or @ procedure(s):
               phterd
               phtsrd
               phtscp
               phtspd
               phtaap

 MODIFICATION HISTORY:
       Written by: C. Gabriel  (ESA-SAI)			Jul 1996
     phtaar + phtcs added (CG)                   		Mar 1998
     phtdrift + phtdyncal added (JAc)		  		Dec 1998
     V7.3

(See /pia_on_line.pro)


PICKMEAS

[Previous Routine] [Next Routine] [List of Routines]
 NAME: 
       PICKMEAS 
 
 PURPOSE: 
       This function allows the user to interactively pick a measurement
	from the PIA internal buffers.  A file 
       selection tool with a simple graphical user interface is created.
 
 CATEGORY: 
       PIA - graphics
 
 CALLING SEQUENCE: 
       Result = PICKMEAS() 
 
 KEYWORD PARAMETERS: 
 
       GROUP:  The widget ID of the widget that calls PICKFILE.  When this 
               ID is specified, a death of the caller results in the death of 
               the PICKFILE widget application. 
 
       FTYPE:  The structure type to be searched.  
 
       TITLE:  A scalar string to be used for the window title.  If it is 
               not specified, the default title is "Select Measurement" 
 
       NOCONFIRM: Return immediately upon selection of a file.  The default 
               behavior is to display the selection and then return the 
               file when the user uses the "ok" button. 

	MULTI: 	When set, several strings can be selected

       POSI:   Position of every selected element 

	COMMENTS: To be printed as text info within widget
 
 OUTPUTS: 
       PICKMEAS returns a string that contains the name of the selected 
       measurement. If no one is selected, PICKMEAS returns a null string. 
 
 COMMON BLOCKS: 
       PICKMEAS: COMMON block that maintains state for the widget. 
 
 SIDE EFFECTS: 
       This function initiates the XMANAGER if it is not already running. 
 
 RESTRICTIONS: 
       Only one instance of the PICKMEAS widget can be running at one time. 
 
 PROCEDURE: 
       Create and register the widget and then exit, returning the measurement 
       name that was picked. 
 
 EXAMPLE: 
 
 PROCEDURES USED:
       Common Block(s) or @ procedure(s):
               adm
               phtaap
               phtcla
               phterd
               phtscp
               phtsmc
               phtspd
               phtsrd
       PIA Procedure(s):
               decode_admn

 MODIFICATION HISTORY: 
       Written by: Carlos GABRIEL
	Oct 95 Version 3.5
       Modified by J. Acosta to include new buffer type (OTHER) - Jan. 96
       Modified by J. Acosta to select within a set of indices  - Mar. 96
	Keyword added to print a text info (JA)			   Jan. 98
	V7.0  
	/Modal use according to IDL >= 5.0 (CG)
	V7.3

(See /pickmeas.pro)


PICKMEAS_POS

[Previous Routine] [Next Routine] [List of Routines]
 NAME: 
       PICKMEAS_pos 
 
 PURPOSE: 
       This function allows the user to interactively pick (a) measurement
	position(s) from the PIA internal buffers.  A file 
       selection tool with a simple graphical user interface is created.
 
 CATEGORY: 
       PIA - graphics
 
 CALLING SEQUENCE: 
       Result = PICKMEAS_pos() 
 
 KEYWORD PARAMETERS: 
 
       GROUP:  The widget ID of the widget that calls PICKFILE.  When this 
               ID is specified, a death of the caller results in the death of 
               the PICKFILE widget application. 
 
       FTYPE:  The structure type to be searched.  
 
       TITLE:  A scalar string to be used for the window title.  If it is 
               not specified, the default title is "Select Measurement" 
 
       NOCONFIRM: Return immediately upon selection of a file.  The default 
               behavior is to display the selection and then return the 
               file when the user uses the "ok" button. 

	MULTI: 	When set, several positions can be selected
 
 OUTPUTS: 
       PICKMEAS returns the position of the selected measurement within the 
       common block. If no one is selected, PICKMEAS returns a zero. 
 
 COMMON BLOCKS: 
       PICKMEAS: COMMON block that maintains state for the widget. 
 
 SIDE EFFECTS: 
       This function initiates the XMANAGER if it is not already running. 
 
 RESTRICTIONS: 
       Only one instance of the PICKMEAS widget can be running at one time. 
 
 PROCEDURE: 
       Create and register the widget and then exit, returning the measurement 
       name that was picked. 
 
 EXAMPLE: 
 
 PROCEDURES USED:
       Common Block(s) or @ procedure(s):
               adm
               phtaap
               phtcla
               phterd
               phtscp
               phtsmc
               phtsmd
               phtspd
               phtsrd
       PIA Procedure(s):
               decode_admn

 MODIFICATION HISTORY: 
       Written by: Carlos GABRIEL (ESA/SAI)		July 1996 
	Modified by CG					October 1996
	V5.x
	/Modal use according to IDL >= 5.0 (CG)
	V7.3

(See /pickmeas_pos.pro)


PIXEL_DET

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	PIXEL_DET
                
PURPOSE:
 	Returns the number of pixels  according to the detector, with the 
	keyword ALLPX include resistor and open pixels
                
 CATEGORY:
       PIA - processing
                
 CALLING SEQUENCE:
       npix = PIXEL_DET(det, [/ALLPX])

 INPUT PARAMETERS:
       det : name of the detector, a two character string [P1,P2,P3,C1,C2,SL]

 KEYWORDS:
	ALLPX:   Including all pixels, resistor + open

 MODIFICATION HISTORY:
       Written by: J.Acosta
       Modified (last) by JA                      February 1997
       V6.1
	Added keywords IS_SPD and IS_AAP	Jacosta  	May 1998
	V7.1

(See /pixel_det.pro)


PLOTDATE

[Previous Routine] [Next Routine] [List of Routines]
 	PROCEDURE: 
		PLOTDATE
 	PURPOSE:
		This procedure puts the user name, calling program and system 
		time and date in the corner of a plot.  
 	CALLING SEQUENCE:
		plotdate, Prog, [Charsize=, Charthick=,/device,/data, /normal]
 	OPTIONAL INPUTS:
		PROG -- Character string containing the name of the calling
			program (Default = 'INTERACTIVE')
	KEYWORD INPUTS:
		SIZE -- Specify the character size.  (Default = 0.35)
		X, Y -- Location to put the string.  (Default is lower right 
			corner, depedning on the current device size).  
		DEVICE -- If present and non-zero, X and Y are in DEVICE 
			  coordinates.  Ignored if X, Y are not both specified.
			  (Default = 1)
		DATA -- If present and non-zero, X and Y are in DATA 
			coordinates.  Ignored if X, Y are not both specified.
			(Default = 0)
		NORMAL -- If present and non-zero, X and Y are NORMALIZED
			  coordinates.  Ignored if X, Y are not both specified.
	NOTE: Only one of [DEVICE, DATA, NORMAL] should be specified.  For 
	      more information regarding these parameters, check documentation
	      of XYOUTS.
	PROCEDURES USED:

 	REVISION HISTORY
		Written by: unknown
 		Modified from RCB::[BOHLIN.IDL]PLOTDATE.PRO 
		Oct 95 Version

(See /plotdate.pro)


PROCESS_PIXEL

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	PROCESS_PIXEL
 PURPOSE:
	Fit voltage ramps of chosen pixel data, taken into 
	account diverse selections or flags plotting the resulting
	ramps slopes with uncertainties
 CATEGORY:
	PIA - processing

 CALLING SEQUENCE:
	PROCESS_PIXEL, TMPDATA, IPIX, NDEG

 INPUT PARAMETERS:
	TMPDATA	: Temporary ERD data structure
	IPIX	: Pixel to be fitted
	NDEG	: Degree of the polynomial to be fitted

 KEYWORD:
	DIV_RAMP: For ramps subdivision

 OUTPUT PARAMETERS:
	TIME	: Array containing slopes times
	SLOP	: Array containing slopes
	SLOPER	: Array containing slopes uncertainties
	SLFLAG	: Array containing slopes flags (0:OK, 1:only two points used,
						 2: bad)


 RESTRICTIONS:

 METHOD:

 PROCEDURES USED:
       Common Block(s) or @ procedure(s):
               phtacc
		splitramp_par
       PIA Procedure(s):
               acc_flg
               acc_volt
               decode_pixf
               fit_ramps

 MODIFICATION HISTORY:
	Written by: C. Gabriel
	Oct 95 Version 3.5
	Call to fit_ramps changed (CG)			March 1996
	Keyword DIV_RAMP added (CG)			May 1997
	V6.3
	Extended for using tmpdata.flag (CG)		November 1997
	V6.6
	Use of bitflag system + new more efficient 
	  data reduction routines (JAcosta)		May 1999
	Data reduction info added (CG)			May 1999
	V7.4
						

(See /process_pixel.pro)


PROCESS_SCP

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	PROCESS_SCP
 PURPOSE:
	Convert PHT data from Signal per Chopper Plateau (SCP) to In-Band-Power 
	per Chopper Plateau (SPD), using default or actual responses to do
	flux calibration. It accomodates the data into the structure PHTSPD.
 CATEGORY:
	PIA - processing
                
 CALLING SEQUENCE:
	PROCESS_SCP, SCPDATA, HDR, RESP, SPDPS, SPDSTR, NO_SPD = NO_SPD, 
		RESPINT=RESPINT 

 INPUT PARAMETERS:
	SCPDATA	: Structure containing the SCP data to be processed
	SCPHDR  : (Updated) Header element corresponding to SCPDATA
	RESP	: Responsivity choice flag - 0=default, 1=calculated, 
				2=absolute photometry, 3=interpolation 
 OPTIONAL KEYWORD :
	NO_SPD	: No structure added to the dynamical structure phtspd
	RESPINT	: Structure to be used for time interpolation (must be
		  set for RESP=3)
	SPRF	: Spectral response function (for PHT-S) to be used

 OPTIONAL OUTPUT:
	SPDPS	: Position of the produced SPD data within the PHTSPD structure 
		  (can be used to check if SPD data has been produced)
	SPDSTR	: Temporary data structure (SPD level)

 RESTRICTIONS:

 METHOD:

 PROCEDURES USED:
       Common Block(s) or @ procedure(s):
               adm
               phtcap
               phtcs
               phtresact
               phtresdef
               phtscp
               phtspd
       PIA Procedure(s):
               cp_disc
               der_spdhdr
               get_wheels
               phtcap_init
               pia_respons_abs
               read_resp

 MODIFICATION HISTORY:
	Written by: C. Gabriel (ESA/ESTEC-SAI)
	Changed (last) by CG				October 1996
	V5.x
	External Flatfield correction + avoid writing twice Resp in hdr by 
	PHT-S and back into SCPHDR (CG)			April 1997
	V6.3
	Baseline drift correction included &
	 quoting responsivity origin in HDR (CG) 	July 1997
	V6.4
	Default responsivity used orbit dependent (CG)	January 1998
	V7.0
	Writing in hdr actual or default respons &	 
	 no use of syst.unc. by def. resp. (CG)		March 1998
	V7.1
	FCS measurements can be flux calibrated, 
	 except for absolute photometry mode (JA)	June 1998
	Using double precision for avoiding underflow (CG) Feb. 1999
	V7.4
	Filter to Filter for P added (CG)		July 1999
	V7.9

(See /process_scp.pro)


PROCESS_SPD

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	PROCESS_SPD
 PURPOSE:
	Convert PHT data from In-Band-Power per Chopper Plateau (SPD) to 
	photometric flux tables (AAP). It accomodates the data into the 
	dynamical structure PHTAAP, returning also the data as a temporary 
	structure.
 CATEGORY:
	PIA - processing
                
 CALLING SEQUENCE:
	PROCESS_SPD, SPDDATA, tmpaap, aapps

 INPUT PARAMETERS:
	SPDDATA	: Structure containing the SPD data to be processed

 OPTIONAL INPUT:
	SPDHDR  : (Updated) Header element corresponding to SPDDATA

 OPTIONAL OUTPUT:
	TMPAAP	: A temporary AAP structure
	AAPPS	: Position of the produced AAP data within the PHTAAP structure 
		  (can be used to check if AAP data has been produced)

 RESTRICTIONS:

 METHOD:

 PROCEDURES USED:
       Common Block(s) or @ procedure(s):
               adm
               phtaap
       PIA Procedure(s):
               flux
	
 MODIFICATION HISTORY:
	Written by: C. Gabriel
	Oct 95 Version 3.5
	Only "good" points entering the AAP structure (CG)	October 1995
	Changed call to flux to avoid warning (CG)		March 1996
	Automatic coordinates setting if not present (CG)	May 1996
	Avoiding division by 0. (CG)				June 1996
	Bug fixed (median brightness from avg. power) (CG)	June 1996
	changed for the aap central wavelength (WMT)            Nov  1996
	Accept also points with FLAG=1 (CG)			Dec 1997
	V6.6
	Changing AAP hdr: new type and PIA version (CG)		March 1998
	Flag system included (JAc)				March 1998
	 but commented until in use (CG)			May 1998
	V7.1 
	Bug introduced in 7.1 for PHT-S fixed (CG)		May 1998
	V7.1.1
	Staring meas. with 1 pixel deselected was wrong 
	treated in flag value. Fixed now. (CG)			December 1998
	V7.3
	Changes according to use of bitflag system (CG)		May 1999
	V7.4 
	Deriving "new" AAP structure with RAP and DECP (CG)	March 2000
	V8.2

(See /process_spd.pro)


PROCESS_SRD

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	PROCESS_SRD
 PURPOSE:
	Reduce PHT data from Signal per Ramp to Signal per Chopper Plateu,
	taken into account diverse selections or flags, and put
	averages, medians, uncertainties, etc. per chopper plateau into the 
	structure phtscp 
	In case of a staring measurement (1 chopper plateaux), data is reduced
	to signal per raster position. 
 CATEGORY:
	PIA - processing
                
 CALLING SEQUENCE:
	PROCESS_SRD, FILES, HDR, SCPPS, DRIFTCORR = driftcorr

 INPUT PARAMETERS:
	FILES	: Array containing the names (phtsrd.admn) of the buffers
		  to be processed
	
 KEYWORDS:
	DRIFTCORR: If set, drift analysis performed

 OPTIONAL INPUT:
	HDR	: HDR string array - can be used for passing updated header 

 OPTIONAL OUTPUT:
	SCPPS	: Array containing the positions of the produced SCP 
		  data within the PHTSCP structure 

 RESTRICTIONS:

 METHOD:

 PROCEDURES USED:
       Common Block(s) or @ procedure(s):
               adm
               phtacc
               phtscp
               phtsrd
       PIA Procedure(s):
               der_scphdr
               get_rastersteps
		mann
       Astronomical Library:
               avg
               sigma

 MODIFICATION HISTORY:
	Written by: C. Gabriel (ESA/VILSPA-SAI)
	Oct 95 Version 3.5
	Drift stability analysis incorporated (CG)	December 1995
	Long integer for loop variable (for more than 32756 signals!) Jan.96
	Drift stability analysis changed:
		at least 8 points required
		if not stable -> take last points (generally 8 but depending on
				 flag) and calculate average and slope change 
	Extension: eff.reset time, eff.nr of readouts & 
	  distribution standard deviation (CG)		January 1996
	Bug fixed: if only partial stable mean was taken instead of
	  weighted mean (CG)				January 1996
	Changeable parameters (common pht_mann_stab) instead of
	  fix parameters for stability analysis (CG)	January 1996

(See /process_srd.pro)


PROCESS_TMPERD

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	PROCESS_TMPERD
 PURPOSE:
	Fit voltage ramps of chosen measurements, taken into 
	account diverse selections or flags and put the resulting
	ramps slopes, uncertainties, etc. into the structure
       phtsrd 
 CATEGORY:
	PIA - processing

 CALLING SEQUENCE:
	PROCESS_TMPERD, TMPERD, NDEG, HDR, SRDPS, ERDPS [,DIV_RAMP=div_ramp]

 INPUT PARAMETERS:
	TMPERD	: Temporary Structure (ERD level) to be processed
	NDEG	: Degree of the polynomial to be fitted


 INPUT KEYWORDS:
	div_ramp: A factor for subdividing ramps when processing

 OPTIONAL INPUT:
	HDR	: String Array containing the file (updated) header

 OPTIONAL OUTPUT:
	SRDPS	: Array containing the positions of the produced SRD 
		  data within the PHTSRD structure
	ERDPS	: Array containing the positions of the input
		  data within the PHTERD structure

 RESTRICTIONS:

 METHOD:

 PROCEDURES USED:
       Common Block(s) or @ procedure(s):
               adm
               phterd
               phtsrd
       PIA Procedure(s):
               acc_flg
               acc_volt
		check_chop
               decode_pixf
               der_shdr
               fit_ramps
               red_ramps
		rpid_check

 MODIFICATION HISTORY:
	Written by JAcosta and CG based on existing process_erd  Nov. 1997
	V6.6
	Check for rpid=[0b,0b] added (CG)			Feb.98
	V7.0
	Bug for checking unc. for extrem long loops fixed (CG)  Jun.98
	V7.2
	Upgrade (larger efficiency) by Jose Acosta (IAC) using
	bitflag system				May 1999
	Data reduction info added (CG)			May 1999
	V7.4
	Bug for splitting into 2 fixed (CG)		August 1999
	V8.0+			
	Call to red_ramps including DR input (CG)	November 1999
	V8.2

(See /process_tmperd.pro)


PROCESS_TMPSRD

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	PROCESS_TMPSRD
 PURPOSE:
	Reduce PHT data from Signal per Ramp to Signal per Chopper Plateu,
	taken into account diverse selections or flags, and put
	averages, medians, uncertainties, etc. per chopper plateau into the 
	structure phtscp. It uses a temporary structure instead of the 
	dynamical structure as process_srd 
 CATEGORY:
	PIA - processing
                
 CALLING SEQUENCE:
	PROCESS_TMPSRD, FILES, HDR, SCPPS, driftcorr=driftcorr

 INPUT PARAMETERS:
	tmpdata	: structure to be processed
	
 KEYWORDS:
	DRIFTCORR: 	If set, drift analysis performed
	DRIFTMOD:  	If set, drift modelling performed
	SLOP_VAR:  	IF set, slopes variation analysis performed
	DRIFTPAR_STR: 	For returning the structure with drift modelling
			results

 OPTIONAL INPUT:
	HDR	: a header to be taken instead of tmpdata.hdr

 OPTIONAL OUTPUT:
	SCPPS	: Array containing the positions of the produced SCP 
		  data within the PHTSCP structure 

 RESTRICTIONS:

 METHOD:

 PROCEDURES USED:
       Common Block(s) or @ procedure(s):
               adm
               phtacc
               phtscp
		phtdrift
       PIA Procedure(s):
               der_scphdr
               get_rastersteps
               get_rpchopstep
		meas_mann
		slop_var
       Astronomical Library:
               avg
               sigma

 MODIFICATION HISTORY:
	Written by: C. Gabriel - ESA/SAI
	Modified (last) by JA + CG 			 February 1997
	V6.1
	Bug for last point manually discarded fixed (CG) March 1997
	Call to fitpar_str_init using CMODE (JA+CG)	 November 1997
	V6.6
	Pattern calibration added (CG)			 June 1999
	 + changed to bitflag system
	Recognition of nodding case added (CG)		 June 1999
	V7.4			 
	Nodding case also for 3xM raster (CG)		July 1999
	+ fix for P32					September 1999
	V8.0
	Bug fixed: STEP variable in nodding case (CG)	November 1999
	V8.1
	Bug fixed: 3x1 P32 case /= nodding (CG)		February 2000
	V8.2

(See /process_tmpsrd.pro)


PROC_INT_RESP

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	PROC_INT_RESP
 PURPOSE:
	Interpolate two FCS measurements for using the interpolated responsivity
	for a series of measurements to be power calibrated
 CATEGORY:
	PIA - processing 
                
 CALLING SEQUENCE:
	PROC_INT_RESP, FCS1, FCS2, measlist

 INPUT PARAMETERS:
	FCS1	: index within phtscp of first FCS measurement to be used
	FCS2    : index within phtscp of second FCS measurement to be used

 OPTIONAL INPUT :
	measlist: index list of measurements to be power calibrated within phtscp

 PROCEDURES USED:
       Common Block(s) or @ procedure(s):
               phtscp

       PIA Procedure(s):
               respons_interpol
               pia_load_iscp
               process_scp

 MODIFICATION HISTORY:
	Written by: C. Gabriel (ESA-SAI)		July 1996

(See /proc_int_resp.pro)


RAMP_2T_DEGLITCH

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	RAMP_2T_DEGLITCH

 PURPOSE:
	Routine for managing the application of the 2 threshold deglitching 
	processing to a measurement, collecting statistics and updating the
	measurement's header 

 CATEGORY:
	PIA - processing

 CALLING SEQUENCE:
	ramp_2t_deglitch, tmpdata, erd_disc, newheader, degl_acc

 INPUT PARAMETERS:
	TMPDATA		: Temporary Structure ERD 
	ERD_DISC	: Flag array (0 = OK, 1 = bad flag)
	NEWHEADER	: Header to be updated

 OUTPUT PARAMETERS:
	TMPDATA		: Updated temporary Structure ERD (If encode_flag=1)
	NEWHEADER	: Updated header
	DEGL_ACC	: Glitches flag array (1=glitch flagged)

 KEYWORD INPUT
	ENCODE_FLAG	: If set, update tmpdata.flag with bitcoded flag
 
 RESTRICTIONS:


 METHOD:

 PROCEDURES USED:
      PIA_internal:
		decode_admn
		pair_deglitch
		pdegl_str_init
		pixel_det

 COMMON BLOCKS:
	pdegl_str
	degl_summary
	degl_string

 MODIFICATION HISTORY:
	Written by: C. Gabriel (ESA-VILSPA/SAI)		January 1998
	V7.0
	Bug for 2 last PHT-S pixels fixed (CG)		February 1998
	V7.1
	Updated for use of bitflag system (CG+JA)	May 1999
	V7.4

(See /ramp_2t_deglitch.pro)


RAMP_DEGLITCH

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       RAMP_DEGLITCH

 PURPOSE:
	Send a measurement to be ramp deglitched, perform statistics,
	write into the header

 CATEGORY:
	PIA - processing

 CALLING SEQUENCE:
       RAMP_DEGLITCH, tmpdata, header, silent=silent

 INPUT:
       tmpdata:
		A real PHT-ERD structure, modified by this process
	
 INPUT KEYWORDS:
	silent:
		Preventing from producing window messages

 OPTIONAL INPUT:
	header:	The header to be modified. If not present, tmpdata.hdr is taken

 PROCEDURES USED:
       Common Block(s) or @ procedure(s):
               phtacc
               degl_ramps_cmn
		degl_summary
		degl_string

 MODIFICATION HISTORY:
       Written by: C. Gabriel (ESA/VILSPA-SAI)		January 1996
	Modification history:
	Updated using FXADDPAR - (CG)			December 1996
	Version 5.5
	Comment extended for low nr of readouts (CG)	September 1997
	V6.5
	Limited to detector pixels, text expanded (CG)	January 1998
	V6.6
	Upgraded with rampend info, use of bitflag
	 system and text output (JAcosta + CG)		May 1999
	Data reduction info added (CG)			May 1999
	V7.4 

(See /ramp_deglitch.pro)


RASTER_INFO

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	RASTER_INFO

 PURPOSE:
	This is not an IDL routine as such, but contains the definition of the
	common block RASTER_INFO for inclusion into other routines. By defining
	the common block in one place, the problem of conflicting definitions
	is avoided.

	This file is included into routines that need this common block with
	the single line (left justified)

				  @raster_info


	This file stores data about raster scans

	RASTER_INFO contains the following variables:

	Att_Type: P(oint), (R)aster or (T)racking
	NPoints: Number of raster points
	NLines: Number of raster lines
	SPoints: Seperation of raster points
	SLines: Seperation of raster lines
	Ins_RA: RA of centre of field of view
	Ins_DEC: DEC of centre of field of view
	Roll: Roll angle
	Orient: Raster orientation

	MRaster: Misalignment of raster scanning
	MPixel: Misalignment of PHT-C pixels
	MChop: Misaligment of chopper throw

 CATEGORY:
	PIA - common block
 PROCEDURES USED:

 MODIFICATION HISTORY:
	Huw Morris, October 1994

(See /raster_info.pro)


READHDR

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	READHDR

 PURPOSE:
	Read in a FITS header (primary or extended).
	The internal file pointer must be positioned at the beginning of
	the header which shall be read in. For the primary header this is
	the beginning of the file, for the extended header this is
	the position of the next FITS record (2880 bytes) just after the
	primary header.

 CATEGORY:
	PIA - I/O

 CALLING SEQUENCE:
	READHDR, lun, header

 INPUTS:
	lun :	The logical unit number of the FITS file, which
		has been opened already.

 KEYWORD PARAMETERS:
	NOEND :		Set this keyword to strip the 'END' card (the last
			non-blank card) from the header.

	ERROR :		Returns and error code:
			0 = no error
			1 = an error occured when reading the file

 OUTPUTS:
	header :	The header (primary or extended, depending on the
			initial position of the file pointer).

 SIDE EFFECTS:
	The FITS file remains open, the file pointer points to the beginning
	of the next FITS record after the header.
 PROCEDURES USED:
	
 MODIFICATION HISTORY:
	Written by: D. Skaley
	Oct 95 Version 3.5

(See /readhdr.pro)


READ_AAR

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       READ_AAR
 PURPOSE:
       Read a PHT-AAR (Auto Analysis Result) file 
 CATEGORY:
       PIA - I/O
 CALLING SEQUENCE:
       READ_AAR, NAME, HEADER, BUFFER [, PATH = PATH ] [, TYPE = TYPE ] 

 INPUT:
       NAME    : Name of AAR FITS file to be read

 OPT. INPUT KEYWORD:
       PATH    : optional path for the file

 OPT. OUTPUTS:
       HEADER  : String array containing the FITS binary table extension
                 header
	BUFFER	: The data itself (real structure)

 OPT. OUTPUT KEYWORD:
       TYPE    : The type of the file read as quoted in phtaar

 
 RESTRICTIONS:
       File must be a valid PHT AAR FITS file
	Except PHT Photometric Image

 PROCEDURES USED:
       Common Block(s) or @ procedure(s):
               adm
               phtcs
               phtaar
       Astronomical Library:
               sxpar
 MODIFICATION HISTORY:
       Written by: Wai-Ming Tai (DIAS)		           Apr, 1996
	Central Wavelengths added to C and P buffers (CG)  January 1997
       PPAS, PCAS read error corrected              (IH)  May 1997
	V6.3
	Type keyword added (CG)				   Apr 1998
	AAR types changed, preventing reading AAR < V9.0 (CG) Mar 2000
	V8.2

(See /read_aar.pro)


READ_ALLPERIGEE

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	READ_ALLPERIGEE
 PURPOSE:
	Read times from all perigee passage from a file created from Mission
	Planning PSFs

 CATEGORY:
       PIA - utilities

 CALLING SEQUENCE:
       READ_ALLPERIGEE
INPUT: 
	rev: Revolution number
	date: Date in the format "16-DEC-1995  7:19:14.00". Is is compatible 
		with tag unit as read from PIA data structures. 
OUTPUT: 
	orbpos: Orbital position in units of 2.4hrs

KEYWORDS: 
	update: it will update file !F_ALLPERIGEE.DAT using read_allpsf

COMMON BLOCKS:
       all_perigee

 PROCEDURES USED:
       ASTRO LIB:
		readcol
       INTERNAL:
		read_allpsf
		unit2juldate

 MODIFICATION HISTORY:
       Written by:     Jose Acosta (PIDT - MPIA)       December 1997
	Added extrapolation (JAc)			February 1998

(See /read_allperigee.pro)


READ_ALLPSF

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
      READ_ALLPSF

 PURPOSE:
	Scan the directory containing all PSFs 
	
 CATEGORY:
       PIA - utilities

 CALLING SEQUENCE:
       read_allpsf [,outfile] [,PSF_DIR =psf_dir] [,/VERBOSE]
INPUT: 

OUTPUT: 
	outfile: name of file to write the date of perigee passage. If not
	         specified then !F_ALLPERIGEE is used
KEYWORDS: 
	verbose: some information is giving about the files reading
	PSF_DIR: repository directory containing Planned Skeleton Files (PSF) 

 PROCEDURES USED:
       ASTRO LIB:
	INTERNAL: 
		read_psf_perigee		

 MODIFICATION HISTORY:
       Written by:     Jose Acosta (PIDT - MPIA)       December 1997

(See /read_allpsf.pro)


READ_ASC_FCSPOW

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
     READ_ASC_FCSPOW
 PURPOSE:
       Read a PHT FCSPOW uplink file.
 CATEGORY:
	PIA - I/O
 CALLING SEQUENCE:
       READ_ASC_FCSPOW, FCSPOW, DET, BUFFER, INPUTFILE = INPUTFILE 

 INPUT:

 OUTPUT:
       FCSPOW: character string of '1' or '2'
       DET: character string of 'C1', 'C2', 'P1', 'P2' and 'P3'
       BUFFER: float array for the FCSPOW table

 OPTIONAL INPUT:
       INPUTFILE: string type for the input uplink file, 
                  default is either one of the following:
                    p_fc1_c1.txt, p_fc1_c2.txt,
                    p_fc2_c1.txt, p_fc2_c2.txt,
                    p_fc1_p1.txt, p_fc1_p2.txt, p_fc1_p3.txt,
                    p_fc2_p1.txt, p_fc2_p2.txt, p_fc2_p3.txt

 PROCEDURES USED:

 MODIFICATION HISTORY:
       Written by: W. M. Tai
	Oct 95 Version 3.5

(See /read_asc_fcspow.pro)


READ_ASC_PDETECT

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
     READ_ASC_PDETECT
 PURPOSE:
       Read a PHT PDETECT uplink file.
 CATEGORY:
	PIA - I/O
 CALLING SEQUENCE:
       READ_ASC_PDETECT, BUFFER, INPUTFILE = INPUTFILE 

 INPUT:
       buffer: float array for the all the P and C detectors
       idark is buffer(0,*)
       nepread is buffer(1,*)
       respons is buffer(2,*)
       eta is buffer(3,*)
       The array are organised as:
           index        detector type
             0            P1
             1            P2
             2            P3
             3            C1
             4            C2
             5            SS
             6            SL

 OUTPUT:

 OPTIONAL INPUT:
       INPUTFILE: string type for the input uplink file, 
                  default is p_pdetect.txt

 OPTIONAL INPUT:

 PROCEDURES USED:

 MODIFICATION HISTORY:
       Written by: W. M. Tai
	Oct 95 Version 3.5

(See /read_asc_pdetect.pro)


READ_ASC_PFILTR

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
     READ_ASC_PFILTR
 PURPOSE:
       Read a PHT PFILTR uplink file.
 CATEGORY:
	PIA - I/O
 CALLING SEQUENCE:
       READ_ASC_PFILTR, BUFFER, INPUTFILE = INPUTFILE 

 INPUT:

 OUTPUT:
       BUFFER: a floating array of 11 X 14, where

 OPTIONAL INPUT:
       INPUTFILE: string type for the input uplink file, 
                  default is p_pfiltr.txt

 PROCEDURES USED:

 MODIFICATION HISTORY:
       Written by: W. M. Tai
	Oct 95 Version 3.5

(See /read_asc_pfiltr.pro)


READ_ASC_PPSF

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
     READ_ASC_PPSF
 PURPOSE:
       Read a PHT PPSF uplink file.
 CATEGORY:
	PIA - I/O
 CALLING SEQUENCE:
       READ_ASC_PPSF, BUFFER, INPUTFILE = INPUTFILE 

 INPUT:

 OUTPUT:
       BUFFER: float array for the PPSF table

 OPTIONAL INPUT:
       INPUTFILE: string type for the input uplink file, 
                  default is p_ppsf.txt

 PROCEDURES USED:

 MODIFICATION HISTORY:
       Written by: W. M. Tai

(See /read_asc_ppsf.pro)


READ_ASC_PSSSL

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
     READ_ASC_PSSSL
 PURPOSE:
       Read a PHT PSSSL uplink file.
 CATEGORY:
	PIA - I/O
 CALLING SEQUENCE:
       READ_ASC_PSSSL, BUFFER, INPUTFILE = INPUTFILE 

 INPUT:

 OUTPUT:
       BUFFER: a floating array of 4 X 128, where
               the 1st column is fpsf
               the 2nd column is Lc
               the 3rd column is the total transmission
               the 4th column is the relative system response

 OPTIONAL INPUT:
       INPUTFILE: string type for the input uplink file, 
                  default is p_ss_sl.txt

 PROCEDURES USED:

 MODIFICATION HISTORY:
       Written by: W. M. Tai
	Oct 95 Version 3.5

(See /read_asc_psssl.pro)


READ_CALA

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       READ_CALA
 PURPOSE:
	Read a PHT CAL-A Data file filling the data into the 
	IDL common PHTCLA. 
 CATEGORY:
	PIA - I/O
 CALLING SEQUENCE:
       READ_CALA, NAME, [HDR], [ILUNR]

 INPUT:
       NAME 	: Name of PHT-CAL-A FITS file to be read
 OPTIONAL INPUT:
       PATH    : path for the file

 OPT. OUTPUTS:
	HDR	: String array containing the FITS binary table extension
		  header

       ILUNR   : Array containing the indices of the measurements in the
                 PHTSPD structure

 RESTRICTIONS:
       File must be a valid PHT-CAL-A FITS file

 PROCEDURES USED:
       Common Block(s) or @ procedure(s):
               adm
               fxbintable
               phtcla
               phtcs
       PIA Procedure(s):
               mergehdr
               phtcs_get_rec
               read_cs
       Astronomical Library:
               fxbclose
               fxbintable
               fxbopen
               fxbread
               fxhread
               fxpar

 MODIFICATION HISTORY:
       Written by: C. Gabriel - ESA/SAI
	Modified (last) by CG			December 1996
	V5.4

(See /read_cala.pro)


READ_CHOPCOR

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       READ_CHOPCOR
 PURPOSE:
       Read the chopper correction factors from calg-G files and store 
       into the COMMON phtchopcor
 CATEGORY:
       PIA - I/O

 CALLING SEQUENCE:
       READ_CHOPCOR

 INPUT PARAMETERS:
       NONE

 OPTIONAL INPUT PARAMETERS:

 OUTPUT PARAMETERS:
       NONE

 RESTRICTIONS:

 METHOD:

 PROCEDURES USED:
       Common Block(s) or @ procedure(s):
               @phtchopcor
       Astronomical Library:
               fxread

 MODIFICATION HISTORY:
       Written by: Jose Acosta                         January 1998
       Version 7.0

(See /read_chopcor.pro)


READ_CRELIN

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	READ_CRELIN
 PURPOSE:
	Read the default PHT CRE linearisations from a FITS file into 
       the COMMON phtcrelin
 CATEGORY:
	PIA - I/O

 CALLING SEQUENCE:
	READ_CRELIN

 INPUT PARAMETERS:
	NONE

 OPTIONAL INPUT PARAMETERS:

 OUTPUT PARAMETERS:
	NONE

 RESTRICTIONS:

 METHOD:

 PROCEDURES USED:
       Common Block(s) or @ procedure(s):
               phtcrelin
       Astronomical Library:
               fxread

 MODIFICATION HISTORY:
	Written by: C. Gabriel
	Oct 95 Version 3.5

(See /read_crelin.pro)


READ_CS

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       READ_CS

 PURPOSE:
	Read a PHT Compact Status file filling the data into the IDL common
	PHTCS. The file has to be a FITS file
       Note that the PHTCS is organised as an array of structure which is
       defined as:
       PHTCS(i) : 
                   unit : strings
                   dim  : interger
                   handle : handle point the collection of array
 
 CATEGORY:
	PIA - I/O

 CALLING SEQUENCE:
       READ_CS, NAME, [HDR], [ILUN]

 INPUT:
       NAME 	: Name of CS FITS file to be read

 KEYWORD:
       PATH    : path for the file
       STATUS  : return 0 if reading is okay, otherwise 1 on error

 OUTPUT:

 OPT. OUTPUTS:
	HDR	: String array containing the FITS binary table extension
		  header

	ILUN	: Unit index in the common


 RESTRICTIONS:
       File must be a valid PHT CS FITS file

 PROCEDURES USED:
       Common Block(s) or @ procedure(s):
               fxbintable
               phtcs
       PIA Procedure(s):
               mergehdr
       Astronomical Library:
               fxbclose
               fxbintable
               fxbopen
               fxbread
               fxhread

 MODIFICATION HISTORY:
       Written by: C. Gabriel
	Modified by: W M Tai
	Oct 95 Version 3.5
	Extended for Serendipity Mode CS files
       optional path added (WMT)                March 1996
	FREE_LUN included! (CG)			 June 1996
	STATUS as keyword (CG)			 January 1997
	V6.0

(See /read_cs.pro)


READ_DARKORB

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	READ_DARKORB
 PURPOSE:
	Read the dark current depending on orbital position from calg-G files  
       into the COMMON phtdarkorb
 CATEGORY:
	PIA - I/O

 CALLING SEQUENCE:
	READ_DARKORB

 INPUT PARAMETERS:
	NONE

 OPTIONAL INPUT PARAMETERS:

 OUTPUT PARAMETERS:
	NONE

 RESTRICTIONS:

 METHOD:

 PROCEDURES USED:
       Common Block(s) or @ procedure(s):
               @phtdarkorb
       PIA library:
        	c2p_pipe2ia: changing order of C2 pixels 
       Astronomical Library:
               fxread

 MODIFICATION HISTORY:
	Written by: Jose Acosta					November 1997
	darkprorp and darkprom initialisation added (CG)	December 1997
	Version 6.6
	Time behaviour for SL included -> SLDARKTIME (JAc)	August 1998

(See /read_darkorb.pro)


READ_ERD

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       READ_ERD
 PURPOSE:
	Read a PHT-ERD (Edited Raw Data) file accomodating the data in  
	structure PHTERD  
 CATEGORY:
	PIA - I/O
 CALLING SEQUENCE:
       READ_ERD, UNIT, NAME, [HDR], [ILUNR], [PATH = PATH]

 INPUT:
       NAME 	: Name of ERD FITS file to be read

 OPT. INPUT:
	PATH    : optional path for the file

 OPT. OUTPUTS:
	HDR	: String array containing the FITS binary table extension
		  header
	ILUNR	: Array containing the indices of the measurements in the
		  PHTERD structure
 RESTRICTIONS:
       File must be a valid PHT ERD FITS file

 PROCEDURES USED:
       Common Block(s) or @ procedure(s):
               adm
               chop_info
               chop_info
               chop_param
               chop_param
               fxbintable
               phtcs
               phterd
       PIA Procedure(s):
               chop_info_init
               chop_param_init
               chop_pos
               conv_cre
               conv_subs
               fcs_pow_conv
               mergehdr
               pia_conv_date
               read_cs
               tmeas_conv
       Astronomical Library:
               fxbintable
               fxpar
               match

 MODIFICATION HISTORY:
       Written by: C. Gabriel - ESA-SAI
	Modified (last) by CG		October 1996
	V5.x
	Change for detecting corrupted parts of the ERD files (CG)	Oct 97
	V6.5
	Keyword FLAG added to ERD dynamical structure (CG)		Nov 97
	V6.6

(See /read_erd.pro)


READ_FCSILL

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	READ_FCSILL
 PURPOSE:
	Read the FCS illumination matrices from the FITS files into 
       the COMMON phtillum
 CATEGORY:
	PIA - I/O

 CALLING SEQUENCE:
	READ_FCSILL[,FILENAME]

 INPUT PARAMETERS:
	NONE

 OPTIONAL INPUT PARAMETERS:
	FILENAME: An alternative file (or array of files) to be read, see
		  restrictions !

 OUTPUT PARAMETERS:
	NONE

 RESTRICTIONS:
	FILENAME must be a valid (or an array of valid) PHT FCSILL fits file(s)
			 AND
		first character must be a P
		2nd and 3rd characters must indicate the detector
		('C1' for C100, 'P1' for P1, etc) 

 METHOD:

 PROCEDURES USED:
       Common Block(s) or @ procedure(s):
               phtillum
       Astronomical Library:
               fxread

 MODIFICATION HISTORY:
	Written by: C. Gabriel - ESA/VILSPA-SAI
	Modified by CG
	Nov 96 Version 5.x
	Change for C200 pixels SPD pipeline convention
	New calibration version: primary FITS with a 4-dim table
	 instead of binary table.
	V6.0

(See /read_fcsill.pro)


READ_FCSPOW

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	READ_FCSPOW
 PURPOSE:
	Read the FCS power tables from the FITS files into 
       the COMMON phtfcspow
 CATEGORY:
	PIA - I/O

 CALLING SEQUENCE:
	READ_FCSPOW[,FILENAME]

 INPUT PARAMETERS:
	NONE

 OPTIONAL INPUT PARAMETERS:
	FILENAME: An alternative file (or array of files) to be read, see
		  restrictions !

 OUTPUT PARAMETERS:
	NONE

 RESTRICTIONS:
	FILENAME must be a valid (or an array of valid) PHT FCSPOW fits file(s)
		located on the !CALG directory
			 AND
		2nd and 3rd characters must indicate the detector
		('C1' for C100, 'P1' for P1, etc) 

 METHOD:

 PROCEDURES USED:
       Common Block(s) or @ procedure(s):
               phtfcs
       Astronomical Library:
               fxread

 MODIFICATION HISTORY:
	Written by: C. Gabriel
	Oct 95 Version 3.5
	Reading also tables validity limits from hdr & putting them into @phtfcs
	V7.0

(See /read_fcspow.pro)


READ_FITS_HEADER

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       READ_FITS_HEADER

 PURPOSE:
       This is part of the pia support routines.
 	And therefore is designed entirely with the pia in mind.
	It is used for reading the external fits header, it
	would trim out the primary endline if the extended
	header exist and join the primary header and the extended
	header together.

 CATEGORY:
       PIA - utilities

 CALLING SEQUENCE:
       READ_FITS_HEADER, FILENAME, HEADER, STATUS

 INPUT:
	FILENAME: the fits filename
	
 OUTPUT:
	HEADER: the returned fits header
	STATUS: the status, -1 is returned if there is error else return 0

 COMMON BLOCKS:

 PROCEDURES USED:
       PIA LIB:
	Astronomical Library:
 MODIFICATION HISTORY:
	Written by: Wai-Ming Tai (DIAS)			March 1996
	mod to pass the current file pointer, WMT(DIAS) Jan 1997

(See /read_fits_header.pro)


READ_FLATFIELD

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	READ_FLATFIELD
 PURPOSE:
	Read the Flat Field Factors from the FITS files into 
       the COMMON phtffield
 CATEGORY:
	PIA - I/O

 CALLING SEQUENCE:
	READ_FLATFIELD[,FILENAME]

 INPUT PARAMETERS:
	NONE

 OPTIONAL INPUT PARAMETERS:
	FILENAME: An alternative file (or array of files) to be read, see
		  restrictions !

 OUTPUT PARAMETERS:
	NONE

 KEYWORDS:
	C1FF:	Flat field array for C100 data - 
		   Full = FLTARR(9,7,2) except if FILTER set (s. FILTER)
	C2FF:	Flat field array for C200 data - 
		   Full = FLTARR(4,5,2) except if FILTER set (s. FILTER)
	PFF:	Filter to filter corr array for P data - 
		   Full = FLTARR(14,2) except if FILTER set (s. FILTER)
	FILTER:	If set and corresponding to the nomenclature of C100/C200
		filters (eg 'C1_50', 'C2_200') then C1FF/C2FF only for this 
		filter (eg FLTARR(9,2) for C100)

 RESTRICTIONS:
	FILENAME must be a valid (or an array of valid) PHT Flatfield (Filter
	to filter) fits file(s)
			 AND
		first character must be a P
		2nd and 3rd characters must indicate the detector
		('PC1' for C100, 'PC2' for C200, 'PPF' for P) 

 METHOD:

 PROCEDURES USED:
       Common Block(s) or @ procedure(s):
               phtillum
       Astronomical Library:
               fxread

 MODIFICATION HISTORY:
	Written by: C. Gabriel - ESA/VILSPA-SAI		May 1997
	V6.3
	Extended for filter to filter file PPFTOF	April 1999
	V7.4

(See /read_flatfield.pro)


READ_FLUXCONV

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	READ_FLUXCONV
 PURPOSE:
	Read the Watts to Jy conversion factors from a FITS file into 
       the COMMON phtw2jy
 CATEGORY:
	PIA - I/O

 CALLING SEQUENCE:
	READ_FLUXCONV

 INPUT PARAMETERS:
	(none)

 OPTIONAL INPUT PARAMETERS:
	FILENAME: The file to be read

 OUTPUT PARAMETERS:
	NONE

 RESTRICTIONS:
	FILENAME must be a valid PHT PFLUXCONV fits file

 METHOD:

 PROCEDURES USED:
       Common Block(s) or @ procedure(s):
               phtw2jy
       Astronomical Library:
               fxhread
               fxpar

 MODIFICATION HISTORY:
	Written by: C. Gabriel (ESA/VILSPA-SAI)		April 1996
	Free_lun instead of close (CG)			May 1996

(See /read_fluxconv.pro)


READ_FOOTPR

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       Read_footpr

 PURPOSE:
	Read the calibration files P#FOOTPR  

 CATEGORY:
       PIA - I/O

 CALLING SEQUENCE:
       Read_footpr, det, fpr, fp_hdr

 INPUT:
	DET:	Detector ('P2', 'C100', 'C1' ...)

 OUTPUT:
	FPR:	The footprint data cube corresponding to DET
	FP_HDR: The header of the footprint FITS file

 KEYWORD PARAMETERS:
	ERROR: 0 if OK, 1 if failed

 COMMON BLOCKS:
	(none)
		
 PROCEDURES USED:
	PIA LIB:
		is_file_exist
       ASTRO LIB:
		fxread
		
 MODIFICATION HISTORY:
       Written by: C. Gabriel (ESA/VILSPA) 			July 1998
	V7.2

(See /read_footpr.pro)


READ_FPGC[1]

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
     READ_FPGC
 PURPOSE:
       Read an Focal Plane Geometry Calibration File and analyse contents
 CATEGORY:
	PIA - I/O
 CALLING SEQUENCE:
 INPUT:
 	infile: name of FPGC file

 OPTIONAL INPUT:

 KEYWORD PARAMETERS:
	ERROR		Returns an error status:
			0 = no error
			1 = error: output is not valid

 PROCEDURES USED:

 MODIFICATION HISTORY:
       Written by: I. Heinrichsen
	Oct 95 Version 3.5

(See /read_anal_fpgc.pro)


READ_FPGC[2]

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
     READ_FPGC
 PURPOSE:
       Read an Focal Plane Geometry Calibration File
 CATEGORY:
	PIA - I/O
 CALLING SEQUENCE:
	read_fpgc, infile, npts, nlin, dst_pts, dst_lin, rota, $
                  rline, rcolumn, ycoor, zcoor, $
		   TEXTOUT=text, ERROR=error 
 INPUT:
 	infile: name of FPGC file

 OPTIONAL INPUT:

 KEYWORD PARAMETERS:
	TEXTOUT		String array containing the vital contents of the 
  			FGPC file
	ERROR		Returns an error status:
			0 = no error
			1 = error: output is not valid
 OUTPUT:
	npts		Number of raster points
	nlin		Number of raster lines
	dst_pts		Distance between raster points [arcsec]
       dst_lin    	Distance between raster legs [arcsec]
	rota		Rotation of raster pattern around raster centre
			in degrees [0.0 .. 360.0]

	rline[npts*nlin]	Raster point id: line number
	rcolumn[npts*nlin]	Raster point id: column number
	ycoor[npts*nlin]	Relative Y-coordinate [arcsec] w.r.t. nominal
				direction of the raster centre
	zcoor[npts*nlin]	Relative Z-coordinate [arcsec] w.r.t. nominal
				direction of the raster centre


 PROCEDURES USED:

 MODIFICATION HISTORY:
       Written by: I. Heinrichsen
	Oct 95 Version 3.5

(See /read_fpgc.pro)


READ_IAAP

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       READ_IAAP
 PURPOSE:
	READ a PHTIAAP (Interactive Astronomical Application Data measurement) 
	file into the dynamical structure PHTAAP  
 CATEGORY:
	PIA - I/O
 CALLING SEQUENCE:
       READ_IAAP, NAME [, IPOS] [, PATH = PATH] [, ADMN = ADMN]

 INPUT:
       NAME 	: IAAP-savefile name

 OPTIONAL INPUT KEYWORD:
	PATH    : path for the file

 OPTIONAL OUTPUT:
	IPOS	: index within phtaap array

 OPTIONAL OUTPUT KEYWORD:
	ADMN	: administration name (phtaap.admn)


 RESTRICTIONS:
       NAME must correspond to a valid PHTIAAP file 

 PROCEDURES USED:
       Common Block(s) or @ procedure(s):
               phtaap

 MODIFICATION HISTORY:
       Written by: C. Gabriel (ESA/SAI)		June 1996
	central wavelength added (WMT)                  Nov 1996
	IPOS added as output argument	(JAcosta)	April 1997	
	Keyword admn added & filename in HDR (CG)	May 1997
	V6.3

(See /read_iaap.pro)


READ_ICLA

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       READ_ICLA
 PURPOSE:
	READ a PHTICLA (Interactive Calibration A measurement) file 
	into the dynamical structure PHTCLA  
 CATEGORY:
	PIA - I/O
 CALLING SEQUENCE:
       READ_ICLA, NAME, PATH = PATH

 INPUT:
       NAME 	: CaL A-savefile name

 OPTIONAL INPUT:
       PATH    : path for the file

 OPTIONAL OUTPUT KEYWORD:
	ADMN	: administration name

 RESTRICTIONS:
       NAME must correspond to a valid PHTICLA file 

 PROCEDURES USED: 
       Common Block(s) or @ procedure(s):
               adm
               phtcla

 MODIFICATION HISTORY:
       Written by: C. Gabriel
	Oct 95 Version 3.5
       optional path added (WMT)                       March 1996
	Keyword admn added & filename in HDR (CG)	May 1997
	V6.3

(See /read_icla.pro)


READ_ICS

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       READ_ICS
 PURPOSE:
	READ a PHTICS (Interactive Compact Status Data) file 
	into the dynamical structure PHTCS 
 CATEGORY:
	PIA - I/O
 CALLING SEQUENCE:
       READ_ICS, NAME, PATH = PATH

 INPUT:
       NAME 	: CS-savefile name

 OPT. INPUT:
	PATH    : path for the file

 RESTRICTIONS:
       NAME must be a valid PHTICS file 

 PROCEDURES USED: 
       Common Block(s) or @ procedure(s):
               phtcs

 MODIFICATION HISTORY:
       Written by: C. Gabriel (ESA/VILSPA-SAI)		December 1995
	optional path added (WMT)		        March 1996

(See /read_ics.pro)


READ_IDB_DEF

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       read_idb_def
 PURPOSE:
       Read data from pht_fm.idb_def data base
 CATEGORY:
	PIA - I/O

 CALLING SEQUENCE:
       read_idb_def,header,idb,idb_ar_table,idb_ar_image

 INPUT PARAMETERS:
       NONE

 OUTPUT PARAMETERS:
       idb         :database array
       idb_ar_table and idb_ar_image with informations about 
              action routines
       header      :header of idb_def file

 RESTRICTIONS:
       NONE
 
 METHOD:
       Store data used for all kinds of idb entries in the first
       17 elements of the idb array, element number 18 contains
       an pointer on a struct of 5 pointers on the 5 posible
       entries: index status analog1 analog2 analog3
       A zero means, that no data of this type is used for
       this entry        

 PROCEDURES USED:
       Astronomical Library:
               boost_array
       Other Procedure(s):
               pht_fm.idb_def

 MODIFICATION HISTORY:
       Written by: Andreas Karch
	Modified by: C Gabriel
	Oct 95 Version 3.5
	Free_lun instead of close (CG)		May 1996

(See /read_idb_def.pro)


READ_IERD

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       READ_IERD
 PURPOSE:
	READ a PHTIERD (Interactive Edited Raw Data measurement) file 
	into the dynamical structure PHTERD  
 CATEGORY:
	PIA - I/O
 CALLING SEQUENCE:
       READ_IERD, NAME [,PATH = PATH] [, ADMN = ADMN]

 INPUT:
       NAME 	: ERD-savefile name
 OPTIONAL INPUT:
	PATH    : path for the file

 OUTPUT KEYWORD:
	ADMN    : administration name (phterd.admn)


 RESTRICTIONS:
       NAME must be a valid PHTIERD file 

 PROCEDURES USED: 
       Common Block(s) or @ procedure(s):
               adm
               phterd
       PIA Procedure(s):
               read_erd

 MODIFICATION HISTORY:
       Written by: C. Gabriel
	Oct 95 Version 3.5
       optional path added (WMT)                       March 1996
	Keyword admn added & filename in HDR (CG)	May 1997
	V6.3

(See /read_ierd.pro)


READ_IRPH

[Previous Routine] [Next Routine] [List of Routines]
  Name:
	Read_IRPH

  Purpose:
	Reads an IRPH attitude file.
 CATEGORY:
	PIA - I/O

  Calling Sequence:
	READ_IRPH, fname, Dec, RA, Roll, UTC, Rpid, RPQ, HDR, 
                  CDEC, CRA, CROLL, CORQ, OTFT   

  Input:
	FName: Name of an IRPH file

  Output:
	Dec :     Uncorrected Raster Point declination
	RA  :     Uncorrected Raster point right ascension
	Roll:     Uncorrected Raster Pont reference roll angle
  	UTC :     Expected UTC of start of pointing
	RPId:     Raster Point ID
	RPQ :     Raster Point quaternion
	Hdr :     FITS header information
       CDEC:     Corrected raster-point reference declination
       CRA :     Corrected raster-point reference right ascension
       CROLL:    Corrected raster-point reference roll angle
       CORQ:     Raster-point correction quaternion
       OTFT:     On-target flag threshold
       
CRA
  Restrictions:
	None

  Procedures Called:
       Astronomical Library:
               fxbclose
               fxbopen
               fxbread
               fxpar

  Modification History
	Written by: Huw Morris
       Modification: New IRPH structure OLP version 6.1 (IH)
	Aug. 97
	Warning added for old filetype (CG)	September 1997
	V6.5
	Finding of old filetype changed to cope with 
	 larger files (CG)			January 1998
	V7.0

(See /read_irph.pro)


READ_ISCP

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       READ_ISCP
 PURPOSE:
	READ a PHTISCP (Interactive Signal per Chopper Plateau) file 
	into the dynamical structure PHTSCP  
 CATEGORY:
	PIA - I/O
 CALLING SEQUENCE:
       READ_ISCP, NAME [, IPOS] [, PATH = PATH] [, ADMN = ADMN]

 INPUT:
       NAME 	: SCP-savefile name
 OPTIONAL INPUT:
	PATH    : path for the file

 OPTIONAL OUTPUT:
	IPOS	: index within phtscp array

 OUTPUT KEYWORD:
	ADMN    : administration name (phtscp.admn)

 RESTRICTIONS:
       NAME must be a valid PHTISCP file 

 PROCEDURES USED: 
       Common Block(s) or @ procedure(s):
               adm
               phtscp

 MODIFICATION HISTORY:
       Written by: C. Gabriel (ESA/ESTEC-SAI)
	Oct 95 Version 3.5
	Structure extension: ARSI, ANDR and AVSD
       add optional path (WMT)                        March 1996
	IPOS added as output argument	(JAcosta)	April 1997	
	Keyword admn added & filename in HDR (CG)	May 1997
       Simplified way of asigning name and saving (JA) May 1997
	V6.3

(See /read_iscp.pro)


READ_ISPD

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       READ_ISPD
 PURPOSE:
	READ a PHTISPD (Interactive Standard Processed Data measurement) file 
	into the dynamical structure PHTSPD  
 CATEGORY:
	PIA - I/O
 CALLING SEQUENCE:
       READ_ISPD, NAME [, IPOS] [, PATH = PATH] [, ADMN = ADMN]

 INPUT:
       NAME 	: ISPD-savefile name

 OPTIONAL INPUT:
	PATH    : path for the file

 OPTIONAL OUTPUT:
	IPOS	: index within phtspd array

 OUTPUT KEYWORD:
	ADMN    : administration name (phtscp.admn)

 RESTRICTIONS:
       NAME must correspond to a valid PHTISPD file 

 PROCEDURES USED:
       Common Block(s) or @ procedure(s):
               adm
               phtspd

 MODIFICATION HISTORY:
       Written by: C. Gabriel
	Oct 95 Version 3.5
	RA, DEC bug fixed + missed keywords (CG)        December 1995
       optional path added (WMT)                       March 1996
	Keyword admn added & filename in HDR (CG)	May 1997
	V6.3

(See /read_ispd.pro)


READ_ISRD

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       READ_ISRD
 PURPOSE:
	READ a PHTISRD (Interactive Signal Data measurement) file 
	into the dynamical structure PHTSRD  
 CATEGORY:
	PIA - I/O
 CALLING SEQUENCE:
       READ_ISRD, NAME [,IPOS] [, PATH = PATH] [, ADMN = ADMN]

 INPUT:
       NAME 	: SRD-savefile name

 OPTIONAL INPUT:
	PATH    : path for the file

 OUTPUT KEYWORD:
	ADMN    : administration name (phtsrd.admn)

 RESTRICTIONS:
       NAME must be a valid PHTISRD file 

 PROCEDURES USED: 
       Common Block(s) or @ procedure(s):
               adm
               phtsrd

 MODIFICATION HISTORY:
       Written by: C. Gabriel (ESA/ESTEC-SAI)		
	Oct 95 Version 3.5
	Structure extension: RESI + NROS (CG)		January 1996 
       optional path added (WMT)                       March 1996
	Added ipos to identify the number in
	PHTSRD buffer  (J.Acosta)			October 1996
	Add uncertainties if equal 0 (CG)		April 1997
	V6.2
	Keyword admn added & filename in HDR (CG)	May 1997
       Simplified way of asigning name and saving (JA) May 1997
	V6.3
	Loop for uncertainty assignment to LONG 
	 corrected (V6.5)				September 1997

(See /read_isrd.pro)


READ_MAP

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       READ_MAP
 PURPOSE:
       Read a PHT-AAR (Auto Analysis Result) file 
 CATEGORY:
       PIA - I/O
 CALLING SEQUENCE:
       READ_MAP, NAME, HEADER, BUFFER, [ PATH = PATH ]

 INPUT:
       NAME    : Name of AAR FITS file to be read

 OPT. INPUT:
       PATH    : optional path for the file

 OPT. OUTPUTS:
       HEADER  : String array containing the FITS binary table extension
                 header
 RESTRICTIONS:
       File must be a valid PHT AAR FITS file
	Except PHT Photometric Image

 PROCEDURES USED:
       Common Block(s) or @ procedure(s):
               adm
               phtcs
               phtaar
       Astronomical Library:
               sxpar
 MODIFICATION HISTORY:
       Written by: Wai-Ming Tai (DIAS)		Apr, 1996

(See /read_map.pro)


READ_OMEGA

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	READ_OMEGA

 PURPOSE:
	This procedure initialises the phtomega and the phtapert common block

 CALLING SEQUENCE:
	READ_OMEGA

 INPUTS:
	None

 OPTIONAL INPUT PARAMETERS:
	FILENAME: An alternative file (or array of files) to be read, see
		  restrictions !

 OUTPUTS:
	None

 RESTRICTIONS:
	FILENAME must be a valid (or an array of valid) PPOMEGA,
	PC1OMEGA or PC2OMEGA fits file(s)
		located on the !CALG directory

 COMMON BLOCKS:
       None

 SIDE EFFECTS:
	The variables in the phtapert and phtomega common block are initialised

 PROCEDURES USED:
	read_ppomega
       read_pc1omega
       read_pc2omega

 MODIFICATION HISTORY:
	Written by: Ingolf Heinrichsen
	Jan 98 Version 1.0
	V7.0

(See /read_omega.pro)


READ_PC1OMEGA

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	READ_PC1OMEGA

 PURPOSE:
	This procedure initialises the phtomega and the phtapert
	common block from the PC1OMEGA.FITS CAL-G file

 CALLING SEQUENCE:
	READ_PC1OMEGA

 INPUTS:
	None

 OUTPUTS:
	None

 COMMON BLOCKS:
       None

 SIDE EFFECTS:
	The variables in the phtapert and phtomega common block are
	initialised with the PHT-C100 information.

 PROCEDURES USED:
       fxbopen, fxbread, fxpar

 MODIFICATION HISTORY:
	Written by: Ingolf Heinrichsen
	Jan 98 Version 1.0
	V7.0
       Free_lun unit after 1st open call (CG)          Jul 99
       V8.0

(See /read_pc1omega.pro)


READ_PC2OMEGA

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	READ_PC2OMEGA

 PURPOSE:
	This procedure initialises the phtomega and the phtapert
	common block from the PC2OMEGA.FITS CAL-G file

 CALLING SEQUENCE:
	READ_PC2OMEGA

 INPUTS:
	None

 OUTPUTS:
	None

 COMMON BLOCKS:
       None

 SIDE EFFECTS:
	The variables in the phtapert and phtomega common block are
	initialised with the PHT-C200 information.

 PROCEDURES USED:
       fxbopen, fxbread, fxpar
       C2P_PIPE2IA

 MODIFICATION HISTORY:
	Written by: Ingolf Heinrichsen
	Jan 98 Version 1.0
	V7.0
	Free_lun unit after 1st open call (CG)		Jul 99
	V8.0

(See /read_pc2omega.pro)


READ_PCPSF

[Previous Routine] [Next Routine] [List of Routines]
 Name:
	READ_PCPSF

 Purpose:
	Reads the PPPSF and the PCPSF FITS file into the common phtppsf
 CATEGORY:
	PIA - I/O
 PROCEDURES USED:
       Common Block(s) or @ procedure(s):
               phtppsf
       Astronomical Library:
		fxbopen
		fxbread
               fxread
 History:
	Written by: Carlos GABRIEL (ESA/VILSPA)		June 1999
	V7.4

(See /read_pcpsf.pro)


READ_PHTHK

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       read_phthk
 PURPOSE:
       Read data from GEHK?.FITS file in arrays hkdat and timestep
 CATEGORY:
	PIA - I/O

 CALLING SEQUENCE:
       read_phthk, tdtnum,hkdat,timestep,header

 INPUT PARAMETERS:
       tdtnum      : tdt number of fits file (as a string,
                     e.g. '00310203'

 OUTPUT PARAMETERS:
       hkdat       :array containing the fits data
       timestep(x) :time for each measurement
       header      :header of fits file

 RESTRICTIONS:
       NONE
 
 METHOD:
       fxbread idl procedure, MERGEHDR       

 PROCEDURES USED:
       PIA Procedure(s):
               mergehdr
       Astronomical Library:
               fxbclose
               fxbopen
               fxbread
               fxhread

 MODIFICATION HISTORY:
       Written by: Andreas Karch 
	Oct 95 Version 3.5
	

(See /read_phthk.pro)


READ_PPOMEGA

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	READ_PPOMEGA

 PURPOSE:
	This procedure initialises the phtomega and the phtapert
	common block from the PPOMEGA.FITS CAL-G file

 CALLING SEQUENCE:
	READ_PPOMEGA

 INPUTS:
	None

 OUTPUTS:
	None

 COMMON BLOCKS:
       None

 SIDE EFFECTS:
	The variables in the phtapert and phtomega common block are
	initialised with the PHT-P information.

 PROCEDURES USED:
       fxbopen, fxbread, fxpar

 MODIFICATION HISTORY:
	Written by: Ingolf Heinrichsen
	Jan 98 Version 1.0
	V7.0
	Free_lun unit after 1st open call (CG)		Jul 99
	V8.0

(See /read_ppomega.pro)


READ_PPSF

[Previous Routine] [Next Routine] [List of Routines]
 Name:
	READ_PPSF

 Purpose:
	Reads the PPSF FITS file into the common phtppsf
 CATEGORY:
	PIA - I/O
 PROCEDURES USED:
       Common Block(s) or @ procedure(s):
               phtppsf
       Astronomical Library:
               fxread
 History:
	Written by: Carlos GABRIEL
	Oct 95 Version 3.5
	Superseded by read_pcpsf - just call to it avoid changing all
	the calls.
	V7.4

(See /read_ppsf.pro)


READ_PSF_PERIGEE

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       READ_PSF_PERIGEE

 PURPOSE:
	Read a PSF file returning the perigee pass time 

 CATEGORY:
       PIA - I/O

 CALLING SEQUENCE:
       read_asc_orbit, psffile, perigee_time

 INPUT:
       psffile: A PSF ascii type file

 OUTPUT:
	perigee_time: The time quoted in psffile as perigee time (in 
		'date_conv' floating format) 

 COMMON BLOCKS:

 PROCEDURES USED:
       ASTRO LIB:
		date_conv

 MODIFICATION HISTORY:
       Written by: J. Acosta  (IAC/ESA)                September 1996
			

(See /read_psf_perigee.pro)


READ_RESP

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	READ_RESP
 PURPOSE:
	Read the default PHT responsivities from a FITS file into 
       the COMMON phtresdef
 CATEGORY:
	PIA - I/O

 CALLING SEQUENCE:
	READ_RESP

 INPUT PARAMETERS:
	NONE

 OPTIONAL INPUT PARAMETERS:
	FILENAME: The file to be read

 OUTPUT PARAMETERS:
	NONE

 RESTRICTIONS:
	FILENAME must be a valid PHT responsivity fits file

 METHOD:

 PROCEDURES USED:
       Common Block(s) or @ procedure(s):
               phtresdef
       Astronomical Library:
               fxhread
               fxpar

 MODIFICATION HISTORY:
	Written by: C. Gabriel
	Oct 95 Version 3.5
	assign uncertainty to responsivity until a value can be read from
	FITS file                            		J. Acosta (Jun-96)
	Changed to pipeline SPD C200 pixel order - CG		December 1996
	V5.5

(See /read_resp.pro)


READ_RESPORB

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	READ_RESPORB
 PURPOSE:
	Read the responsivity depending on orbital position from calg-G files  
       into the COMMON phtresporb
 CATEGORY:
	PIA - I/O

 CALLING SEQUENCE:
	READ_RESPORB

 INPUT PARAMETERS:
	NONE

 OPTIONAL INPUT PARAMETERS:

 OUTPUT PARAMETERS:
	NONE

 KEYWORDS:
     filename:       Array of filenames to be used as input. If not set, 
                     the default is: [PPRESP_02,PC1RESP_02,PC2RESP_02],
                     FITS files residing on !FITDIR.

 RESTRICTIONS:

 METHOD:

 PROCEDURES USED:
       Common Block(s) or @ procedure(s):
               @phtresporb
       PIA library:
        	c2p_pipe2ia: changing order of C2 pixels 
       Astronomical Library:
               fxread

 MODIFICATION HISTORY:
	Written by: Carlos GABRIEL (ESA/VILSPA-SAI)		January 1998
	V7.0
	Bug for case of NO keyword filename fixed (CG)		April 1998
	V7.1

(See /read_resporb.pro)


READ_RLIN_TABLE

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	READ_RLIN_TABLE
 PURPOSE:
	Read an ASCII table as designed for the signal linearization
 CATEGORY:
	PIA - I/O
                
 CALLING SEQUENCE:
	READ_RLIN_TABLE, TABLE, SIG_IN, SIG_OUT, LIMITS

 INPUT PARAMETERS:
	table:		filename of the table
	
 KEYWORDS:
	(none)

 OUTPUT:
	sig_in	: 	Array containing signals as observed
	sig_out : 	Array (same dims as sig_in) containing corrected signals
			after detector response linearization
	limits  :	2-elements array containing lower und upper validity
			bounds

 PROCEDURES USED:

       Astronomical Library:
               readcol

 MODIFICATION HISTORY:
	Written by: C. Gabriel - ESA-VILSPA/SAI 		Dec.98

(See /read_rlin_table.pro)


READ_SCP

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       READ_SCP
 PURPOSE:
	READ a PHTSCP (Interactive Signal per Chopper Plateau) fits file 
	into the dynamical structure PHTSCP  
 CATEGORY:
	PIA - I/O
 CALLING SEQUENCE:
       READ_SCP, NAME

 INPUT:
       NAME 	: SCP-fitsfile name

 OPT. INPUT:
	PATH    : path for the file

 RESTRICTIONS:
       NAME must be a valid PHTSCP fits file 

 PROCEDURES USED: 
       Common Block(s) or @ procedure(s):
               adm
               phtscp
       PIA Procedure(s):
               mergehdr
       Astronomical Library:
               fxpar

 MODIFICATION HISTORY:
       Written by: W M Tai (adapted from C Gabriel in read_iscp.pro)
	optional path added
	add three new fields to the phtscpt, (arsi, andr and avsd) 
	change rpid to byte array
							(WMT)  Mar 96
	Oct 95 Version 3.5
	mod to use read_fits_header.pro                 (WMT)  Jan 97

(See /read_scp.pro)


READ_SELNDR

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	READ_SELNDR
 PURPOSE:
	Read the Pipeline non-destructive read-outs selection criteria 
	from a FITS file into COMMON phtselndr
 CATEGORY:
	PIA - I/O

 CALLING SEQUENCE:
	READ_SELNDR[,FILENAME]

 INPUT PARAMETERS:
	NONE

 OPTIONAL INPUT PARAMETERS:
	FILENAME: An alternative file to be read, see
		  restrictions !

 OUTPUT PARAMETERS:
	NONE

 RESTRICTIONS:
	FILENAME must be a valid PHT SELNDR fits file(s)
		located on the !FITDIR directory

 METHOD:

 PROCEDURES USED:
       Common Block(s) or @ procedure(s):
               phtselndr
       Astronomical Library:
               fxbclose
               fxbopen
               fxbread

 MODIFICATION HISTORY:
	Written by: C. Gabriel
	Oct 95 Version 3.5

(See /read_selndr.pro)


READ_SPD

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       READ_SPD
 PURPOSE:
	Read a PHT-SPD (Standard Processed Data) file accomodating the data 
	structure PHTSPD  
 CATEGORY:
	PIA - I/O
 CALLING SEQUENCE:
       READ_SPD, NAME, [HDR], [ILUNR], [PATH = PATH]

 INPUT:
       NAME 	: Name of PHT-SPD FITS file to be read
 OPTIONAL INPUT:
	PATH    : path for the file

 OPT. OUTPUTS:
	HDR	: String array containing the FITS binary table extension
		  header
       ILUNR   : Array containing the indices of the measurements in the
                 PHTSPD structure

 RESTRICTIONS:
       File must be a valid PHT-SPD FITS file

 PROCEDURES USED:
       Common Block(s) or @ procedure(s):
               adm
               fxbintable
               phtcs
               phtspd
       PIA Procedure(s):
               c2p_pipe2ia
               mergehdr
               phtcs_get_rec
               read_cs
       Astronomical Library:
               fxbclose
               fxbintable
               fxbopen
               fxbread
               fxhread
               fxpar

 MODIFICATION HISTORY:
       Written by: C. Gabriel - ESA-SAI
	Modified by Wai-Ming Tai (DIAS) and CG 		September 1996
	V.5.0 - Sept. 96
	Problem with different nomenclature for SPD files
	 from pipeline fixed (CG)			September 1997
	V6.5

(See /read_spd.pro)


READ_SPD_SL

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       READ_SPD_SL
 PURPOSE:
	Read a PHT-SPD (Standard Processed Data) file corresponding to 
	PHT-SS or PHT-SL accomodating the data into the structure PHTSPD  
 CATEGORY:
	PIA - I/O
 CALLING SEQUENCE:
       READ_SPD_SL, NAME, [HDR], [ILUNR], [PATH = PATH]

 INPUT:
       NAME 	: Name of PHT-SPD FITS file to be read

 OPTIONAL INPUT:
	PATH    : path for the file

 OPT. OUTPUTS:
	HDR	: String array containing the FITS binary table extension
		  header
       ILUNR   : Array containing the indices of the measurements in the
                 PHTSPD structure

 RESTRICTIONS:
       File must be a valid PHT-SPD FITS file

 PROCEDURES USED:
       Common Block(s) or @ procedure(s):
               adm
               fxbintable
               phtcs
               phtspd
       PIA Procedure(s):
               c2p_pipe2ia
               mergehdr
               phtcs_get_rec
               read_cs
       Astronomical Library:
               fxbclose
               fxbintable
               fxbopen
               fxbread
               fxhread
               fxpar

 MODIFICATION HISTORY:
       Written by: C. Gabriel (ESA/VILSPA-SAI)		December 1995
	optional path added (WMT)                       March 1996
	abort reading if cs file not found              March 1996
	Free_lun instead of close (CG)			May 1996
	change to accomodate the ss/sl spd to scp       Sept 1996
	structure, we have to merge the sl and ss 
	files together in the scp structure
	Extension to IA produced files (CG)		Oct 1997
	V6.5

(See /read_spd_sl.pro)


READ_SPECAL

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	READ_SPECAL
 PURPOSE:
	Read the Volts/s to Jy conversion factors from a FITS file into 
       the COMMON phtw2jy
 CATEGORY:
	PIA - I/O

 CALLING SEQUENCE:
	READ_SPECAL

 INPUT PARAMETERS:
	(none)

 OPTIONAL INPUT PARAMETERS:
	FILENAME: The file to be read

 OUTPUT PARAMETERS:
	NONE

 RESTRICTIONS:
	FILENAME must be a valid PHT PSPECAL fits file

 METHOD:

 PROCEDURES USED:
       Common Block(s) or @ procedure(s):
               phtw2jy
       Astronomical Library:
               fxhread
               fxpar

 MODIFICATION HISTORY:
	Written by: C. Gabriel (ESA/VILSPA-SAI)		April 1996
	Last change by CG - New calfile 		January 1997
       keyword ATABLE added to read an ASCII table 
					    (JAcosta)   May 1997
	V6.3

(See /read_specal.pro)


READ_SPECAL_CHOP

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       READ_SPECAL_CHOP
 PURPOSE:
       Read the Volts/s to Jy conversion factors and first order correction
	for SL chopped measurement from a FITS file into the COMMON phtslchopp. 
 CATEGORY:
       PIA - I/O

 CALLING SEQUENCE:
       READ_SPECAL_CHOP

 INPUT PARAMETERS:
       (none)

 OPTIONAL INPUT PARAMETERS:
       FILENAME: The file to be read
       PATH: The directory to find the file to be read
	TABLE: To read a savefile instead of cal-G file

 OUTPUT PARAMETERS:
       NONE

 RESTRICTIONS:
       FILENAME must be a valid PHT PSPECAL fits file

 METHOD:

 PROCEDURES USED:
       Common Block(s) or @ procedure(s):
               phtslchopp
       Astronomical Library:
               fxhread
               fxpar

 MODIFICATION HISTORY:
       Written by: J. Acosta (IAC)         			Feb. 1999
       V7.3
	Upgrade (CG)						Jul. 1999
	V7.9

(See /read_specal_chop.pro)


READ_SRD

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       READ_SRD
 PURPOSE:
	READ a PHTSRD (Interactive Signal Data measurement) fits file 
	into the dynamical structure PHTSRD  
 CATEGORY:
	PIA - I/O
 CALLING SEQUENCE:
       READ_SRD, NAME

 INPUT:
       NAME 	: SRD-fitsfile name

 OPT. INPUT:
       PATH    : path for the file

 RESTRICTIONS:
       NAME must be a valid PHTSRD fits file 

 PROCEDURES USED: 
       Common Block(s) or @ procedure(s):
               adm
               phtsrd
       PIA Procedure(s):
               mergehdr
               read_isrd
       Astronomical Library:
               fxpar

 MODIFICATION HISTORY:
       Written by: W M Tai (adapted from C Gabriel in read_isrd.pro)
	Modified (last) by CG		November 1996
	V5.x
	Bug fixed (long headers) - CG	January 1997
	V6.x

(See /read_srd.pro)


REBUILD_RAMPS

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	REBUILD_RAMPS

 PURPOSE:
	reconstruct a ramp which is affected by glitches. It looks for the
	median of unaffected readout differences and use that to 
       reconstruct the readout jumps. It works only for an individual ramp. 

 CATEGORY:
	PIA - processing

 CALLING SEQUENCE:
    newramp = REBUILD_RAMPS (time, ramp, indok, indreb)

 INPUTS:
	time	: Vector containing the independent variable [t]  (same size)
	ramp	: Vector containing the individual readouts
	indok	: Index containing the good readouts
	indreb  : Index containing the readouts to rebuild 

 OUTPUTS:
	newramp : Array containing the repaired readouts

 KEYWORD INPUT:

 RESTRICTIONS:
	time, ramp and redflag must have the same number of elements

 PROCEDURES USED:
	None

 MODIFICATION HISTORY:
	Written by:	Jose Acosta 				      May 1999	
	V7.4

(See /rebuild_ramps.pro)


RED_RAMPS

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	RED_RAMPS
 PURPOSE:
	Reduce several variables from read-out level to signal level. Return
	chopper pos., temp., FCS values, time key and raster point per ramp
	using the flag status for taking just the selected read-outs
 CATEGORY:
	PIA - processing

 CALLING SEQUENCE:
    red_ramps, tmperd, st, chincr, rampend, otf, dr, $
	ychop, ystep, yfcsn, ytemp, yfcs1, yfcs2, ytkey, yrpid, ycflg

 INPUT PARAMETERS:
	TMPERD	: Temporary Structure ERD 
	ST	: Flag status (0 = OK, 1 = bad flag)
	CHINCR	: Chopper increment
	RAMPEND : Ramp end status array (1=end)
	OTF	: Flag-array for On Target Flag (ERD level)
	DR	: Destructive Read-out Flag (ERD level)

 OUTPUT PARAMETERS:
	YCHOP	: Array - medians of chopper position / ramp
	YSTEP	: Array - medians of chopper step / ramp
	YFCSN	: Array - medians of chopper fcsn value / ramp
	YTEMP	: Array - interpolated temperatures / ramp
	YFCS1	: Array - medians of FCS1 el. power / ramp
	YFCS2	: Array - medians of FCS2 el. power / ramp
	YTKEY	: Array - initial instr. Time Key / ramp
	YRPID	: Array - medians of  raster position / ramp
	YCFLG	: Array - flags for chopper position
	YOTF	: Array - flags for On Target Flag



 RESTRICTIONS:
	DR and ST must have the same number of elements as variables in
	TMPERD

 METHOD:

 PROCEDURES USED:
       Astronomical Library:
               avg
               boost_array

 MODIFICATION HISTORY:
	Written by: C. Gabriel
	Modified by CG - PIA V5.x	October 1996
	Bug for very strange configuration (subdivision + 1 element/ramps 
	  accepted) fixed (CG)		July 1997
	V6.4
	Signal chopper positions defined using
	 all read-outs + check for consistency 
	 and corresponding flags (CG)	September 1997
	Change for 1 read-out in ramp (CG)	February 1998
	V7.1
	Upgraded using ramp end info (JAcosta)	May 1999
	Bug for ramp with no valid reads fixed (CG)	May 1999
	OTF input, YOTF output added
	Bug for RPID value when no valid reads fixed (CG)	August 1999
	V8.0
	DR input added for fixing bug (OTF flag) in case of two
	read-outs ramps (CG)					November 1999
	V8.2
	

(See /red_ramps.pro)


REPLACE_FCSPRE_STR

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       REPLACE_FCSPRE_STR
 PURPOSE:
       Replace Pre-reduced Signals current structure corresponding 
	to det 
 CATEGORY:
	PIA - I/O
 CATEGORY:
       
 CALLED SEQUENCE:
       REPLACE_FCSPRE_STR, DETECTOR_NAME, newfcspre_str
 INPUTS:
       DETECTOR_NAME: ONE OF THESE STRINGS -- P1, P2, P3, C1, C2
       newfcspre_str: the corresponding new Pre-reduced signals structure
 OPTIONAL INPUTS:
       NONE
 KEYWORD PARAMETERS:
       NONE
 PROCEDURE:
 MODIFICATION HISTORY:
       WRITTEN BY: Carlos GABRIEL (ESA/VILSPA-SAI)	February 1996

(See /replace_fcspre_str.pro)


REPLACE_FCSPSTR

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       REPLACE_FCSPSTR
 PURPOSE:
       Replace FCSP current structure corresponding 
	to det 
 CATEGORY:
	PIA - I/O
 CATEGORY:
       
 CALLED SEQUENCE:
       REPLACE_FCSPSTR, DETECTOR_NAME, newfcspstr
 INPUTS:
       DETECTOR_NAME: ONE OF THESE STRINGS -- P1, P2, P3, C1, C2
       newfcspstr: the corresponding new FCS powers structure
 OPTIONAL INPUTS:
       NONE
 KEYWORD PARAMETERS:
       NONE
 PROCEDURE:
 MODIFICATION HISTORY:
       WRITTEN BY: Carlos GABRIEL (ESA/VILSPA-SAI)	February 1996

(See /replace_fcspstr.pro)


RESPCHK_STR_INIT

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       RESPCHK_STR_INIT

 PURPOSE:
       Initializes the Responsivity check Structures

 CATEGORY:
	PIA - initialisation

 CALLING SEQUENCE:
       RESPCHK_STR_INIT

 INPUTS:
       None

 OUTPUTS:
       None

 PROCEDURES USED:
       None

 MODIFICATION HISTORY:
       Written by:	Jose Acosta
	May 97 Version 6.4

(See /respchk_str_init.pro)


RESPONS_INTERPOL

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       RESPONS_INTERPOL
 PURPOSE:
	Interpolates two PHT-Fcs measurements, writing as actual responsivity
	the weighted average of both (after user's choice) into the common
	block phtrespact 
 CATEGORY:
	PIA - processing

 CALLING SEQUENCE:
       RESPONS_INTERPOL, fcs1, fcs2, resps[,NO_WIDGET=no_widget] 

 INPUT:
       fcs1: index within PHTSCP of the first fcs measurement  
	fcs2: index within PHTSCP of the second fcs measurement  

 KEYWORD:
	no_widget: PIA_respons call with /no_widget
	outlim	 : Set to 1 if OUT_of_limits of at least one of both fcs set

 OUTPUT:
	resps: A structure containing
		resp1: responsivity calculated with the fcs1 measurement
		respun1: resp1 uncertainty
		time1: measurement's date (taken from fcs1.unit)
		orig1n: admn name 1st FCS
		orig1f: filter 1st FCS
		orig1m: method used 1st FCS
		resp2: responsivity calculated with the fcs2 measurement
		respun2: resp2 uncertainty
		time2: measurement's date (taken from fcs2.unit)
		orig2n: admn name 2nd FCS
		orig2f: filter 2nd FCS
		orig2m: method used 2nd FCS

 RESTRICTIONS:

 PROCEDURES USED:
       Common Block(s) or @ procedure(s):
               phtresact
               phtscp
       PIA Procedure(s):
               pia_load_iscp
               pia_respons
               weight_mean

 MODIFICATION HISTORY:
       Written by: C. Gabriel
	Oct 95 Version 3.5
	Passing back responses and uncertainties (CG)	February 1996
	pia_respons call changed (CG)			July 1996
	Keyword NO_widget added (CG)			June 1997
	V6.3
	Output keyword outlim added (CG)		February 1998
	V7.1
	Extension of resps for info inclusion (CG)	July 99
	V7.4

(See /respons_interpol.pro)


RESPONS_STR_INIT

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       RESPONS_STR_INIT
 PURPOSE:
       Initializes the Responsivity Structures
 CATEGORY:
	PIA - initialization

 CALLING SEQUENCE:
       RESPONS_STR_INIT

 INPUT PARAMETERS:
       None

 OUTPUT PARAMETERS:
       None

 PROCEDURES USED:

 MODIFICATION HISTORY:
       Written by: Carlos GABRIEL
       Modified by: Wai-Ming Tai
	Oct 95 Version 3.5
	New structure definition (CG)		November 1995
	Structure extension (CG)		December 1995
	Structure extension (JAcosta)		April	 1996

(See /respons_str_init.pro)


RLIN_PROC

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	RLIN_PROC

 PURPOSE:
	Apply the signal linearization to an SRD/SCP PHT measurement

 CATEGORY:
	PIA - Processing
                
 CALLING SEQUENCE:
	RLIN_PROC, TMP, NEWHDR=NEWHDR, SRD=SRD, SIG_COR=SIG_COR 

 INPUT PARAMETERS:
	tmp:		temporary SRD or SCP structure (it get updated) (**)
	
 KEYWORDS:
	SRD:		to be set if measurement of SRD level

 OPT.INPUT KEYWORDS:
	newhdr:		measurement header (it get updated)

 OPT.OUTPUT KEYWORDS:
	sig_cor:	the corrected signals after linearization
		 	
 KEYWORDS:
	INFO		getting the messages instead of the console

 OUTPUT:
	sig_in	: 	Array containing signals as observed
	sig_out : 	Array (same dims as sig_in) containing corrected signals
			after detector response linearization
	limits  :	2-elements array containing lower und upper validity
			bounds

 PROCEDURES USED:

 (**) NOTE: all affected variables are changed
	accordingly, eg. slun in the SRD case, and avun, medi, q1me, q3me 
	in the SCP case.

 MODIFICATION HISTORY:
	Written by: C. Gabriel - ESA-VILSPA/SAI 		Dec.98
	INFO keyword added (CG)					Jun.99
	Other variables changed (slun ...) CG			Jun.99
	V7.4
	rlin_tables under !CALG (CG)				Jul 99
	V7.9
	Bug in uncertainty removed (CG)				Jul 99
	Call to rlin_fct including det as keyword (CG)		Jul 99
	V8.0

(See /rlin_proc.pro)


ROUTINE_NAME

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	ROUTINE_NAME

 PURPOSE:
	Include help text for pia_multi_fit

 CATEGORY:
          PIA - support

 	Used with kind permission of the SWS IDT. Imported into PIA from SWS 
	interactive analysis routine library.
	    
#> multi_fit_help.dc1
 Identifier     multi_fit_help.pro

 Purpose        Including help text for multi_fit.pro  

 Synopsis       multi_fit_help, help_ident
                                    
 Arguments      Name           I/O   Type     Description
                -----------------------------------------------------
                help_ident      I    string    help ident
                
 Returns        ---

 Description    ---    

 Comment        Currently in german 
               
 Example        ---

 Category       CAS

 Filename       multi_fit_help.pro

 Author         K.Seidenschwang

 Version        1.0

 History        1.0  03-apr-1995  --> KS  first draft
#<

(See /multi_fit_help.pro)


SCP2AAP_SL

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	SCP2AAP_SL

 PURPOSE:
	Convert from tmpscp structure to AAP, using a given calibration

 CATEGORY:
	PIA - processing

 CALLING SEQUENCE:
	scp2aap_SL, tmpscp, flux_str, aapps, NEWHDR = newhdr, $
	       INFO = info 

 INPUT PARAMETERS:
	tmpscp: a valid scp structure (only PHT-S)
	flux_str: structure containing the calibrated signals. It has the 
	     following tags: flux_str={flave:FLTARR(128),flunc:FLTARR(128), $
				       flmed:FLTARR(128),flq1:FLTARR(128),  $
				       flq3:FLTARR(128),flflag:FLTARR(128)}
 OUTPUT PARAMETERS:
	aapps: index of PHTAAP structure array
			     
 KEYWORD PARAMETERS:
	INFO: a string array containing info about processing
	NEWHDR: an updated header which will go into AAP structure	     
			     
 COMMON BLOCKS:
	phtaap
		     
 PROCEDURES USED:
	PIA LIB:
       ASTRO LIB:
       INTERNAL:
 MODIFICATION HISTORY:
       Written by: J.Acosta (ISO-SOC/VILSPA)          		  Feb 1999
	V7.3
	Flag changed - taking it from SCP structure (CG)	  Feb 1999
	V7.4
	Header keyword PRA_CDYN added (CG)			  Sept. 1999
	V8.1
			

(See /scp2aap_sl.pro)


SCP_INIT

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       scp_init
 PURPOSE:
       Initializes the structure PHTSCP defining the contents as
	a template structure PHTSCP_TYPE. It can be used for clearing
	the whole SCP structure, in case this should show as necessary. 
 CATEGORY:
	PIA - initialization

 CALLING SEQUENCE:
       SCP_INIT

 INPUT PARAMETERS:
	None       

 OUTPUT PARAMETERS: 
	None

 KEYWORDS:
	Index:	If set, only those will be deleted from buffer

 PROCEDURES USED:
       Common Block(s) or @ procedure(s):
               phtscp

 MODIFICATION HISTORY:
       Written by: C. Gabriel
	Oct 95 Version 3.5
	Free handles added (CG)			January 1996
	use scp_fist_handle and scp_last_handle (WMT) May 1996
	Keyword index for clearing set of records added (CG+JA)	May 1997
	V6.3

(See /scp_init.pro)


SEP_RP

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	SEP_RP

 PURPOSE:
	Separate an ERD measurement into pieces per RPID

 CATEGORY:
	PIA - processing

 CALLING SEQUENCE:
	SEP_RP, tmperd

 INPUT PARAMETERS:
	tmperd	: temporary (real) ERD structure

 OUTPUT PARAMETERS:
	(none)

 RESTRICTIONS:
	tmperd must be a temporary real structure

 SIDE EFFECTS:
	phterd buffer increase by (rasterpoints * rasterlines) measurements 

 METHOD:

 PROCEDURES USED:
       Common Block(s) or @ procedure(s):
               phterd

 MODIFICATION HISTORY:
	Written by: C. Gabriel (ESA/VILSPA - SAI)		1996
	Bug for last raster point fixed (CG)			June 1997
	V6.4
	Change accordingly to new keyword in ERD structure
	 phterd.flag (CG)					February 1998
	V7.1
	Bug fixed: temperature 2-dim for SL (CG)		August 1999
	V8.0

(See /sep_rp.pro)


SEP_RP_CHOP

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	SEP_RP_CHOP

 PURPOSE:
	Separate an array per raster point and chopper position computing
	  the corresponding weighted means und uncertainties

 CATEGORY:
	PIA - processing

 CALLING SEQUENCE:
	SEP_RP_CHOP, flux, flunc, rpid, step, flout, flounc, flpos

 INPUTS:
	flux: 	a 2 dimensional array (eg mnpw(9,1200)
	flunc:	the corresponding uncertainty array
	rpid:	the raster point id array (eg rpid(2,1200))
	step:	the chopper step array (PIA convention!)

 KEYWORD PARAMETERS:
	(none)

 OUTPUTS:
	flout:	the "flux" array averaged per raster point and chopper pos.
	flounc:	the corresponding uncertainty array
	flpos:	a string array with one entry per rpid/chpos combination

 PROCEDURES USED:
	PIA Procedure(s):
		weight_mean

 COMMON BLOCKS:
	(none)

 MODIFICATION HISTORY:
	Written by: 	C. Gabriel, ESA/VILSPA		July 1996

(See /sep_rp_chop.pro)


SET_COLOURS

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       set_colours
 PURPOSE:
 	Loads the color tables for the CEB plotting 
 CATEGORY:
	PIA - graphics

 CALLING SEQUENCE:
        set_colours

 INPUT PARAMETERS:
        NONE

 OUTPUT PARAMETERS:
       NONE

 RESTRICTIONS:
       NONE
 
 METHOD:

 PROCEDURES USED:
       Common Block(s) or @ procedure(s):
               colour_indices

 MODIFICATION HISTORY:
       Written by: S. R. Williams
	Oct 95 Version 3.5
	White copied to position 10 (CG)		February 1996
	Loading the b-w table first (CG)		July 1996
	Loading the individual colors in the last 12
	positions and inserting rainbow in first 116	May 1999
	V7.4

(See /set_colours.pro)


SET_ORBPOS

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	SET_ORBPOS
 PURPOSE:
	Given a revolution and date compute the orbital position 
 CATEGORY:
       PIA - utilities

 CALLING SEQUENCE:
       orbpos = set_orbpos(rev, date)
INPUT: 
	rev: Revolution number
	date: Date in the format "16-DEC-1995  7:19:14.00". Is is compatible 
		with tag unit as read from PIA data structures. 
OUTPUT: 
	orbpos: Orbital position in units of 2.4hrs

 PROCEDURES USED:
       ASTRO LIB:
		juldate
       INTERNAL:
		read_allperigee
		unit2juldate

 MODIFICATION HISTORY:
       Written by:     Jose Acosta (PIDT - MPIA)       December 1997

(See /set_orbpos.pro)


SET_SLWAVELEN

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       set_slwavelen
 PURPOSE:
       Fill the array slwavelen (in PHTSLWAVLEN) containing the SS and SL 
	wavelengths
 CATEGORY:
	PIA - processing

 CALLING SEQUENCE:
       set_slwavelen

 INPUT PARAMETERS:
       NONE

 OUTPUT PARAMETERS:
       NONE

 RESTRICTIONS:
       NONE
 
 METHOD:
	Call to READ_SPECAL (read PSPECAL.FITS)

 PROCEDURES USED:
       Common Block(s) or @ procedure(s):
               phtslwavlen
       PIA Procedure(s):
               read_specal

 MODIFICATION HISTORY:
       Written by: Carlos GABRIEL
	Oct 95 Version 3.5
	Now just as intermediate call to READ_SPECAL (CG)	April 1996

(See /set_slwavelen.pro)


SGCHOPCOR

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       SGCHOPCOR

 PURPOSE:
       Perform the correction for signal losses in a chopped measurement.
       

 CATEGORY:
       PIA - processing

 CALLING SEQUENCE:
       SGCHOPCORR, tmpdata

 INPUT PARAMETERS:
	tmpdata: Background subtracted measurement
        
 OUTPUT PARAMETERS:
       

 MODIFICATION HISTORY:
       Written by: J. Acosta                           NOVEMBER 1997
       Version 6.6

(See /sgchopcor.pro)


SKY_COORDS

[Previous Routine] [Next Routine] [List of Routines]
 Name:
	Sky_Coords

 Purpose:
	Maps image co-ordinates onto equatorial co-ordinates
 CATEGORY:
	PIA - processing

 Input:
	xa: x image co-ordinate
	ya: y image co-ordinate

 Output:
	RA: RA of co-ordinate
	Dec: Dec of co-ordinate
	Roll_Ang: Roll Angle
	RA_Unc: Uncertainty in the RA
	Dec_Unc: Uncertainty in the Dec
	Roll_Unc: Uncertainty in the roll

 Restrictions: 
	Assumes the raster_info common block has been initialised

 Procedures Called:
       Common Block(s) or @ procedure(s):

 Modification History:
	Written by: Huw Morris (adapted from Simon Williams)
	Oct 95 Version 3.5

(See /sky_coords.pro)


SLOP_VAR

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	SLOP_VAR

 PURPOSE:
	Calculate slop variations in time intervals  

 CATEGORY:
	PIA - processing

 CALLING SEQUENCE:
	SLOP_VAR, tmpdata, rpchopsteps, sig_disc, slop_var_str

 INPUT:
	tmpdata: 	An SRD temporary structure
	rpchopsteps:	The raster/chopper combination steps
	sig_disc:	A flag array corresponding to tmpdata.slop

 KEYWORD PARAMETERS:
	
 OUTPUT:
	slop_var_str:	A structure containing the slopes variations per time
			interval and pixel, uncertainties, averages, initial
			and final signals.	
	
 COMMON BLOCKS:
	(none) 
		
 METHOD:
	Divide into time intervals per raster point and chopper position:
	time intervals are given by 2^n seconds, (n > 1).

 MODIFICATION HISTORY:
	Written by: C. Gabriel - ESA/SAI	  December 1996
	Version 5.5
	Bug fixed - JA+CG			  February 1997
	V6.1
			

(See /slop_var.pro)


SPD_DISC

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       spd_disc
 PURPOSE:
       Return a flag array with flag=2 for all the chopper plateaux
       discarded using the bitflag system
 CATEGORY:
	PIA - processing

 CALLING SEQUENCE:
       spd_disc, tmpdata, flagarr

 INPUT PARAMETERS:
       tmpdata: PHTSPD type temporary structure

 OUTPUT PARAMETERS:
       flagarr: Flag array of dimensions (# pixels, # chopper plateaux)
		 # pixels does not include resistor and open pixel  

 RESTRICTIONS:
       NONE
 
 METHOD:
       Use the SPD discard criteria within PHTACC to flag all chopper
       plateaux to be deselected        

 PROCEDURES USED:
       Common Block(s) or @ procedure(s):
               phtacc

 MODIFICATION HISTORY:
       Written by: Carlos GABRIEL
	Oct 95 Version 3.5
	Changed according to bitflag system (CG)
	V7.4

(See /spd_disc.pro)


SPD_INIT

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       spd_init
 PURPOSE:
       Initializes the structure PHTSPD defining the contents as
	a template structure PHTSPD_TYPE. It can be used for clearing
	the whole SPD structure, in case this should show as necessary. 
 CATEGORY:
	PIA - initialization

 CALLING SEQUENCE:
       SPD_INIT

 INPUT PARAMETERS:
	None       

 OUTPUT PARAMETERS: 
	None

 KEYWORDS:
	Index:	If set, only those will be deleted from buffer

 PROCEDURES USED:
       Common Block(s) or @ procedure(s):
               phtspd
               phtspd_init

 MODIFICATION HISTORY:
       Written by: C. Gabriel
	Oct 95 Version 3.5
	Keyword index for clearing set of records added (CG+JA)	May 1997
	V6.3

(See /spd_init.pro)


SPHDIST

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	SPHDIST

 PURPOSE:
	SPHDIST calculates the distance between two points on a sphere.
	SPHDIST is also able to calculate the distance between a single point
	and a series of points or between two series of points.

 CATEGORY:
       Astronomy.

 CALLING SEQUENCE:
	RESULT = SPHDIST( RA1, DEC1, RA2, DEC2 )

 INPUTS:
	RA1:	Flt scalar or array; specifying the right ascension of point 1
		[degrees].
	DEC1:	Flt scalar or array; specifying the declination of point 1
		[degrees].
	RA2:	Flt scalar or array; specifying the right ascension of point 2
		[degrees].
	DEC2:	Flt scalar or array; specifying the declination of point 2
		[degrees].

 OPTIONAL INPUT PARAMETERS:
       None.

 OPTIONAL INPUT KEYWORDS:
	None.

 OUTPUTS:
	SPHDIST returns the distance on the sphere between [RA1,DEC1] and
	[RA2,DEC2] [degrees]. If the input variables are arrays, SPHDIST
	returns an array of the same size.

 OPTIONAL OUTPUT PARAMETERS:
	None.

 OPTIONAL OUTPUT KEYWORDS:
	None.

 COMMON BLOCKS:
	None.

 SIDE EFFECTS:
       None.

 RESTRICTIONS:
	RA1 and DEC1 must have the same dimensions, as well as RA2 and DEC2.
	If RA1, DEC1 are arrays, then RA2, DEC2 must either have the same size
	or must be scalars. In this case, the distance of [RA2,DEC2] to each
	of the points specified in [RA1,DEC1] is returned. The same applies to
	the opposite case.

 MODIFICATION HISTORY:
       created by: Stefan Bogun            MPIA Heidelberg
       	    March, 1995

(See /mapaap2drizzle.pro)


SPLITRAMP_PAR

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	SPLITRAMP_PAR

 PURPOSE:
	Definition of the common block SPLITRAMP_PAR for inclusion into other 
	routines.  
	the common block contains information about the parameters used for
	ramp splitting.

 CATEGORY:
       PIA - common block

 CALLING SEQUENCE:
	@splitramp_par

 COMMON BLOCK PARAMETERS:
	splitramp_par: structure for ramp splitting parameters

 MODIFICATION HISTORY:
	Wrtten by: Carlos GABRIEL(ESA/VILSPA) 	May 1997
	Version 6.3

(See /splitramp_par.pro)


SPLITRAMP_PAR_INIT

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	SPLITRAMP_PAR_INIT

 PURPOSE:
	Initialize the common block SPLITRAMP_PAR. 

 CATEGORY:
       PIA - I/O

 CALLING SEQUENCE:
	splitramp_par_init

 COMMON BLOCKS:
	@splitramp_par

 MODIFICATION HISTORY:
	Wrtten by: Carlos GABRIEL(ESA/VILSPA) 	May 1997
	Version 6.3

(See /splitramp_par_init.pro)


SRD_INIT

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       srd_init
 PURPOSE:
       Initializes the structure PHTSRD defining the contents as
	a template structure PHTSRD_TYPE. It can be used for clearing
	the whole SRD structure, in case this should show as necessary. 
 CATEGORY:
	PIA - initialization

 CALLING SEQUENCE:
       SRD_INIT

 INPUT PARAMETERS:
	None       

 OUTPUT PARAMETERS: 
	None

 KEYWORDS:
	Index:	If set, only those will be deleted from buffer

 PROCEDURES USED:
       Common Block(s) or @ procedure(s):
               phtsrd
               phtsrd_init

 MODIFICATION HISTORY:
       Written by: C. Gabriel
	Oct 95 Version 3.5
	Free handles added (CG)			January 1996
	mod to use srd_first_handle and srd_last_handle   (WMT) May 1996
	Keyword index for clearing set of records added (CG+JA)	May 1997
	V6.3

(See /srd_init.pro)


SUBDARK_SCP

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       SUBDARK_SCP

 PURPOSE:
       Subtract dark current at scp level, log info into the header. 
	It checks if the dark current has been subtracted before.

 CATEGORY:
	PIA - processing

 CALLING SEQUENCE:
       subdark_scp, scptmp, hdr

 INPUTS:
	scptmp:    Temporal phtscp structure

 OPTIONAL INPUTS:
       hdr:	   Current header 

 COMMON BLOCKS:
       none
 PROCEDURES USED:
	PIA Procedure(s):
		darkcur
       Astrolib:
		fxpar, fxaddpar

 MODIFICATION HISTORY:
       Written by: 	Jose Acosta (ISO-SOC, Vilspa)	May 1997
	V6.3
	Bug fixed: bringing back updated header

(See /subdark_scp.pro)


SUBTR_BCKG

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	SUBTR_BCKG

 PURPOSE:
	Return subtractions of chopper plateaux, using neighbour chopper 
	chopper plateaux positions and interpolating for the
	background to be subtracted if required
 CATEGORY:
	PIA - processing

 CALLING SEQUENCE:
	Subtr_bckg, tmpdata, srcst, srcsubt, bckstep=bckstep, SPD=spd

 INPUTS:
	tmpdata: A structure containing data (SCP or SPD level)
	srcst: The chopper step to subtract from (if 98 central position is
 		taken for triangular and sawtooth chopping, or 2 for others)

 KEYWORD PARAMETERS:
	BCKSTEP: The chopper step to be subtracted - (if not present or 99
		 interpolation of all other steps) 	
	ISPD:	 (0 if SCP level, 1 if SPD, 2 if AAP)
	
 OUTPUTS:
	srcsubt: Structure containing
		name: measurement name
		level: 'SCP' or 'SPD'
		aver: array (pixel #,ch.pl) of averages (src - bck)
		avun: aver uncertainty array
		bcav: array (pixel #,ch.pl) of background as used for
		      subtraction
		bcun: bcav uncertainty array
		medi: array (pixel #,ch.pl) of medians (src - bck)
		m1qu: array (pixel #,ch.pl) of first quartiles (src - bck)
		m3qu: array (pixel #,ch.pl) of third quartiles (src - bck)
		flag: array (pixel #,ch.pl)
	
 OPTIONAL OUTPUTS:
	
 SIDE EFFECTS:
	
 RESTRICTIONS:
	
 METHOD:
	
 EXAMPLE:
	
 CALLED ROUTINES:
	
 COMMON BLOCKS:

 PROCEDURES USED:
       Common Block(s) or @ procedure(s):
               phtcs
       PIA Procedure(s):
               conv_subs
               cp_discl
               read_cs
               spd_disc
	
 MODIFICATION HISTORY:
	Written by: C.Gabriel
	Oct 95 Version 3.5
	Bug for SS ('SL' in CS) fixed (CG)		December 1995
	cp_discl instead of cp_disc used (CG)		March 1996
	Avoiding crash if no interpolation possible
	 because of only 1 bck point (CG)		March 1999
	V7.4

(See /subtr_bckg.pro)


SUBTR_DARSTR_MEAS

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       SUBTR_darstr_MEAS

 PURPOSE:
	Subtract an SCP level dark current or straylight measurement from 
	a source or FCS measurement, replacing the contents into the 
	dynamical common block PHTSCP 

 CATEGORY:
	PIA - processing

 CALLING SEQUENCE:
       SUBTR_darstr_MEAS, src_meas, bck_meas, subt_meas, STRAY=stray

 INPUT:
       src_meas:
		A real SCP structure containing the source measurement
       bck_meas:
		A real SCP structure containing the background measurement
 INPUT KEYWORDS:
	STRAY:
		indicating subtraction of straylight measurement
	REPL_INDEX:
		giving the position within the scp common to put the 
		subtracted measurement

 OUTPUT:
	subt_meas:
		A real SCP structure containing the subtr. measurement


 SIDE EFFECTS:

 RESTRICTIONS:

 PROCEDURES USED:
       Common Block(s) or @ procedure(s):
               adm
               phtscp
		phtspd

 MODIFICATION HISTORY:
       Written by: C. Gabriel (ESA/VILSPA-SAI)		December 1996
	REPL_INDEX keyword added (CG)			June 1997
	V6.4
	Measurement name added if Warning (CG)		August 1999
	V8.0

(See /subtr_darstr_meas.pro)


SUBTR_MEAS

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       SUBTR_MEAS

 PURPOSE:
	Subtract an SCP or SPD level measurement from another one, writing the
	results into the dynamical common block PHTSCP 

 CATEGORY:
	PIA - processing

 CALLING SEQUENCE:
       SUBTR_MEAS, src_meas, bck_meas, subt_meas, SPD=SPD

 INPUT:
       src_meas:
		A real SCP or SPD structure containing the source measurement
       bck_meas:
		A real SCP or SPD structure containing the background measurement
 INPUT KEYWORDS:
	SPD:
		indicating SPD level subtraction
	AAP:
		indicating AAP level subtraction
	NO_AP:
		not using apertures normalization
	NO_WIDGET: 
		to avoid showing a widget with subtraction info.
	INDPHT
		the index of subtracted measure in PHTXXX structure 

 OUTPUT:
	subt_meas:
		A real SCP or SPD structure containing the subtr. measurement


 SIDE EFFECTS:
	The dynamical structure phtscp (or phtspd) is increased on one record
	containing the subtracted measurement.

 RESTRICTIONS:

 PROCEDURES USED:
       Common Block(s) or @ procedure(s):
               adm
               phtscp
		phtspd

 MODIFICATION HISTORY:
       Written by: C. Gabriel (ESA/VILSPA-SAI)		January 1996
	Extension for keywords ARSI, ANDR and AVSD (CG) January 1996
	Apertures normalization introduced - 
	  No_AP keyword added  (CG)			April 1996
	Information added on buffer name (CG)		April 1996
	Extended for AAP subtraction (CG)		November 1997
	V6.6
	For normalisation by different apertures take
	 omegas instead of aperture sizes (CG)		January 1998
	V7.0
	Number of pixels for PHT-S SPD/AAP fixed (CG)	July 1998
	V7.2
	Use CASE instead of IF ELSE, use FILL_xxx routines, 
	and update of PIA_MNAM keyword in the header (JAc)	Dec 1998
	V7.3
	Bug for aperture normalization case fixed +
	 warning added in case of measurements with
	 different filters/apertures (CG)			June 1999
	V7.4

(See /subtr_meas.pro)


TMEAS_CONV, RAW_TMP, DET_MODE, CONV_TMP

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	TMEAS_CONV, RAW_TMP, DET_MODE, CONV_TMP
 PURPOSE:
  To convert measured temperatures from telemetry
 CATEGORY:
	PIA - processing

 CALLING SEQUENCE:
	TMEAS_CONV, RAW_TMP, DET_MODE, CONV_TMP

 INPUT:
  RAW_TMP  - integer, raw (telemetered) temperature(s)
  DET_MODE - char str, the modeword for this subsystem

 OUTPUT:
	CONV_TMP - real, converted temperature(s)

 DESCRIPTION:
  Uses the subsystem-dependent conversion parameters to
  convert the raw telemetered detector temperature values
  using the algorithm defined in "Converting Algorithms for
  Telemetry Data" (TN 2096-8100DS/01).

              Namely : T [ `C] =             B
                                    -----------------------------
                                    log10(Rs) + (K /log10 Rs) - A

              where

                       Rs [Ohm] = 1000 * [          1              - Rk]
                                           -----------------------
                                           [      1           -  1 ]
                                            ----------------    ---
                                             C1 * TMDATA - C2    Rp

  The quantities A, B, K, C1, C2, RP_1 (1/Rp)  and Rk
  are accessed from an array using the modeword as a key.


 PROCEDURES USED:
	NONE

 MODIFICATION HISTORY:
	Written by: W. M. Tai
	Oct 95 Version 3.5

(See /tmeas_conv.pro)


UNIT2JULDATE

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
      UNIT2JULDATE

 PURPOSE:
	convert the usual format of date ("DD-Mon-YYYY HH:MM:SS.S") to reduced 
	Julian date
 CATEGORY:
       PIA - utilities

 CALLING SEQUENCE:
       jd = unit2juldate(date)
INPUT: 
	date: Date in the format "16-DEC-1995  7:19:14.00". Is is compatible 
		with tag unit as read from PIA data structures. 
OUTPUT: 
	jd: Reduced julian date

 PROCEDURES USED:
       ASTRO LIB:
		juldate
 MODIFICATION HISTORY:
       Written by:     Jose Acosta (PIDT - MPIA)       December 1997

(See /unit2juldate.pro)


VIGNET

[Previous Routine] [Next Routine] [List of Routines]
 Name:
	Vignet

 Purpose:
	To correct for chopper amplitude dependent vignetting
 CATEGORY:
	PIA - processing

 Input:
	SubInst: PHT Sub-instrument: One of P1, P2, P3, C1, C2, SL
	In_Slop: Array of uncorrected averaged slopes for plateaux
	In_Slun: Corresponding array of uncertainties associated with each
                slope
	Chop: Chopper position for each slope
	Fcsn: FCS active for each slope
	Pixel: Pixel number for PHT-C100 (0 - 8), PHT-C200 (0 - 3)
	       Aperture number for PHT-P (0 - 13)
	Filter: Filter position number (1 - Max_filter)

 Output:
	Out_Slop: Array of corrected averaged slopes for plateaux
	Out_Slun: Corresponding array of uncertainties associated with each
	          slope

 KEYWORDS:
	FCORRECTION: the computed correction factors (same dimm as in_slop)

 Restrictions:
	All input arrays must be of the same size
	The vignetting correction tables must have been read in first

 Procedures Used:
       Common Block(s) or @ procedure(s):
               phtvignet

 Modification History:
	Written by: Huw Morris
	Modified by: C Gabriel
	Oct 95 Version 3.5
	

(See /vignet.pro)


VIGNET_TABLES_READ

[Previous Routine] [Next Routine] [List of Routines]
 Name:
	Vignet_Tables_Read

 Purpose:
	Read the Vignetting Correction Tables into a common block
 CATEGORY:
	PIA - initialization

 Input:
	None

 Output:
	None:

 Restrictions:
	The five correction files must be available

 Procedures Used:
       Common Block(s) or @ procedure(s):
               phtvignet
       Astronomical Library:
               fxread

 Modification History:
	Written by: Huw Morris
	Modified by: C Gabriel
	Oct 95 Version 3.5
	Changed to pipeline SPD C200 pixel order - CG		December 1996
	V5.5

(See /vignet_tables_read.pro)


WEIGHT_MEAN

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	WEIGHT_MEAN
 PURPOSE:
  To perform a weighted mean returning also the standard deviation

 CATEGORY:
	PIA - processing

 CALLING SEQUENCE:
	WEIGHT_MEAN, DATA, UNC, MEAN, [STDV], [SIGMA] [, /MEDIAN] $
		[,SET_WEIGTH = SET_WEIGHT] [,MINNR = MINNR]

 INPUT:
  	DATA  - A one-dimensional array of values
  	UNC   - An array of same dimensions as data with uncertainties

 OPTIONAL INPUT:
	MEDIAN - If set, returns median instead of weighted mean 
	SET_WEIGHT - A vector defining the weighting factors
       MINNR  - If set, the minimum number of points required to weight the
              mean. By default, if less than 15 elements, then simple average
              is taken.

 OUTPUT:
	MEAN - The weighted mean

 OPTIONAL OUTPUT:
	STDV - The standard deviation of the mean
	SIGMA - The standard deviation of the distribution

 DESCRIPTION:

 PROCEDURES USED:
	NONE

 RESTRICTIONS:
	At least 15 points or MINNR are required for weighted mean, if less 
	normal average is returned.

 MODIFICATION HISTORY:
	Written by: C.Gabriel
	Modified: Threshold and limit added - CG	December 1996 
	Limit changed - CG				December 1996
	V5.5
	If no weight use weights=1. (CG)		June 1997
	V6.4
	SET_WEIGHT keyword introduced to use as proper 
	weight (JA) 					July 98
	Keyword MINNR added (CG)			September 1998
	V7.3

(See /weight_mean.pro)


WHEELS2ID

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       WHEELS2ID

 PURPOSE:
       Returns the filter and aperture id's corresponding to the 
	wheels and detector specified

 CATEGORY:
	PIA - processing

 CALLING SEQUENCE:
	wheels2id, det, wheels, filt_id, aper_id, lambda=lambda

 INPUT:
	det:		Detector name
	wheels:		3-array containing the wheel positions

 OUTPUT:
	filt_id:	Official filter identifier - (string)      
	aper_id:	Official aperture identifier - (string)       

 OPTIONAL OUTPUT:
	lambda:		Central Wavelength
	area:		Aperture area (in mm^2)

 COMMON BLOCKS:
	phtapertures:	Apertures and their sizes
	phtfilter:	Filters' IDs

 MODIFICATION HISTORY:
       Written by: Carlos GABRIEL (ESA-SAI)	November 1995
	Bug with C filters fixed (CG)		December 1995
	Adapted for phtapert CB from OMEGA (CG)	February 1998
	V7.0

(See /wheels2id.pro)


WRITEFITS_MOD

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	WRITEFITS_MOD
 PURPOSE:
	Write an an IDL array into a disk FITS file.    Works with all types
	of FITS files except random groups

 CALLING SEQUENCE:
	writefits, filename, data [, header, NaNvalue = , /APPEND] 

 INPUTS:
	FILENAME = String containing the name of the file to be written.

	DATA = Image array to be written to FITS file.    If DATA is 
              undefined or a scalar, then only the FITS header (which
              must have NAXIS = 0) will be written to disk

 OPTIONAL INPUT:
	HEADER = String array containing the header for the FITS file.
		 If variable HEADER is not given, the program will generate
		 a minimal FITS header.

 OPTIONAL INPUT KEYWORD:
       NaNvalue - Value in the data array to be set to the IEEE NaN
                 condition.   This is the FITS representation of undefined
                 values 
       APPEND - If this keyword is set then the supplied header and data
                array are assumed to be an extension and are appended onto
                the end of an existing FITS file.    Note that the primary
                header in the existing file must already have an EXTEND
                keyword to indicate the presence of an FITS extension.

 OUTPUTS:
	None

 RESTRICTIONS:
       (1) It recommended that BSCALE and BZERO not be used (or set equal
           to 1. and 0) with REAL*4 or REAL*8 data.
       (2) WRITEFITS will remove any group parameters from the FITS header

 EXAMPLE:
       Write a randomn 50 x 50 array as a FITS file creating a minimal header.

       IDL> im = randomn(seed, 50, 50)        ;Create array
       IDL> writefits, 'test', im             ;Write to a FITS file "test"

 PROCEDURES USED:
       CHECK_FITS, HOST_TO_IEEE, SXDELPAR, SXADDPAR, SXPAR

 MODIFICATION HISTORY:
	WRITTEN, Jim Wofford, January, 29 1989
       MODIFIED, Wayne Landsman, added BITPIX = -32,-64 support for UNIX
       Use new BYTEODER keywords 22-Feb-92
       Modify OPENW for V3.0.0   W. Landsman       Dec 92
       Work for "windows"   R. Isaacman            Jan 93
	More checks for null data                   Mar 94

	Bug caused by the use of host_to_ieee fixed
	Routine name changed (C. Gabriel)	    Jul 98
	Changed for x86 (linux) as little endian (CG) Mar 99
	V7.4

(See /writefits_mod.pro)


WRITE_AAP_SL

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       WRITE_AAP_SL
 PURPOSE:
       Write a PHT-AAP (Astrophysical Applications Product) measurement from a  
       temporary structure of AAP type onto a FITS binary table file
 CATEGORY:
       PIA - I/O
 CALLING SEQUENCE:
       WRITE_AAP_SL, TMPDATA[, tmphdr]

 INPUT:
       tmpdata : PHTAAP temporary structure
 
 OPTIONAL INPUT:
       tmphdr  : PHTAAP header

 OPTIONAL KEYWORD:
       filename: filename to store the FITS file

 RESTRICTIONS:
       tmpdata must be a valid PHT_S AAP temporary structure
	(either staring or chopped subtracted)

 PROCEDURES USED: 
       Common Block(s) or @ procedure(s):
		phtslwavlen

 MODIFICATION HISTORY:
       Written by: Min Y. Hur				Feb 1999
	Small modifications by CG			Feb 1999
	V7.4
	Modified to reflect the new AAP structure (MH)	Mar 2000
	V8.2

(See /write_aap_sl.pro)


WRITE_ACC

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	WRITE_ACC
 PURPOSE:
	To write acceptance criteria for read-outs 
	into the read-out acceptance block
 CATEGORY:
	PIA - I/O

 CALLING SEQUENCE:
	WRITE_ACC, NSEL,DRN,NDR1,NDRN,MIR,MAR,ANR,SIG1,SIGN,MIS,MAS,ANS,$
		   CPN,MIC,MAC,ACP,MINV,MAXV

 INPUT PARAMETERS:
	NSEL	: 1 if general NDR selection rules used, 0 if not 
	DRN	: 0 if DR to be accepted, 1 if not 
	NDR1	: 0 if first NDR to be accepted, 1 if not
	NDRN	: Array of NDRs to be neglected
       MIR	: First Read-out (absolute) to be accepted
	MAR  	: Last Read-out (absolute) to be accepted
	ANR	: Any Read-out (absolute) to be neglected
	MINV	: Minimum voltage to be accepted
	MAXV	: Maximum voltage to be accepted 
	SIGF	: Structure giving the fraction to be taken for chopped/n.chop.
	SIG1	: 0 if first Signal/Chopper Plateau to be accepted, 1 if not
	SIGN	: Array of Signals/Ch.Plateau to be neglected
       MIS	: First Signal (absolute) to be accepted
	MAS  	: Last Signal (absolute) to be accepted
	ANS	: Any Signal (absolute) to be neglected
	CPN	: Array of contiguous Ch.Plateaux to be neglected
	MIC	: First Chopper Plateau to be accepted
	MAC	: Last Chopper Plateau to be accepted
	ACP	: Array of non-contiguous Ch.Plateaux to be neglected
	SPN	: Array of contiguous Ch.Plateaux to be neglected (SPD level)
	MSC	: First Chopper Plateau to be accepted (SPD level)
	MCC	: Last Chopper Plateau to be accepted  (SPD level)
	ACC	: Array of non-contiguous Ch.Plateaux to be neglected (SPD level)


 OUTPUT PARAMETERS:
	NONE

 RESTRICTIONS:
	NONE

 METHOD:
 PROCEDURES USED:
       Common Block(s) or @ procedure(s):
               phtacc

 MODIFICATION HISTORY:
	Written by: C. Gabriel
	Oct 95 Version 3.5

(See /write_acc.pro)


WRITE_ASC_FCSPOW

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
     WRITE_ASC_FCSPOW
 PURPOSE:
	Write a PHT FCSPOW to an uplink file.
 CATEGORY:
	PIA - I/O
 CALLING SEQUENCE:
       WRITE_ASC_FCSPOW, FILENAME, FCSPOW, TRS_NUM, DETECTOR, FCSPOW_TABLE
                   INST_TAB = INST_TAB, 
                   VERSION = VERSION, AUTHOR = AUTHOR

 INPUT:
       filename: uplink file name 
       fcspow: character string of '1' or '2'
       trs_id: character string of '1' or '2'
       det: character string of 'C1', 'C2', 'P1', 'P2', 'P3'
       talble: fcspow table, 4 dimensional array of
               45 * detector pixels * 2 * 2

 OPTIONAL INPUT:
       INST_TAB : string to identify the instrument table, eg P_FC1_C1
       VERSION : the version number, string type, (00.00)
                 default is 00.01
       AUTHOR : author, string type, default is PHT IDT

 PROCEDURES USED: 
       Common Block(s) or @ procedure(s):
               phtoptpow

 MODIFICATION HISTORY:
       Written by: W. M. Tai
	Oct 95 Version 3.5

(See /write_asc_fcspow.pro)


WRITE_ASC_PDETECT

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
     WRITE_ASC_PDETECT
 PURPOSE:
       Write a PHT PDETECT to an uplink file.
 CATEGORY:
	PIA - I/O
 CALLING SEQUENCE:
       WRITE_ASC_PDETECT, DETECTOR, IDARK = IDARK, NEPREAD = NEPREAD, 
                   RESPONS = RESPONS, ETA = ETA,
                   INPUTFILE = INPUTFILE, OUTPUTFILE = OUTPUTFILE,
                   INST_TAB = INST_TAB,
                   VERSION = VERSION, AUTHOR = AUTHOR

 INPUT:
       detector: character strings of the detector, (P1, P2, P3, C100,
                 C200, SS and SL)

 OPTIONAL INPUT:
       IDARK: dark current, floating point
       NEPREAD: nepread detector noise, floating point
       RESPONS: responsivity, floating point
       ETA: quantum efficiency of detector, floating point
       INPUTFILE: string type for the input uplink file, 
                  default is p_detect.txt
       OUTPUTFILE: string type for the output uplink file, 
                  default is p_detect_pia.txt
       INST_TAB : string to identify the instrument table, eg P_DETECT
       VERSION : the version number, string type, (00.00)
                 default is 00.01
       AUTHOR : author, string type, default is PHT IDT

 PROCEDURES USED:

 MODIFICATION HISTORY:
       Written by: W. M. Tai
	Oct 95 Version 3.5

(See /write_asc_pdetect.pro)


WRITE_ASC_PFILTR

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
     WRITE_ASC_PFILTR
 PURPOSE:
       Write a PHT PFILTR uplink file.
 CATEGORY:
	PIA - I/O
 CALLING SEQUENCE:
       WRITE_ASC_PFILTR, BUFFER, INPUTFILE = INPUTFILE,  
                   INST_TAB = INST_TAB,
                   VERSION = VERSION, AUTHOR = AUTHOR

 INPUT:
       column: Column in the table (0 < column < 12)
       BUFFER: a floating array of 14

 OPTIONAL INPUT:
       INPUTFILE: string type for the input uplink file, 
                  default is p_pfiltr.txt
       OUTPUTFILE: string type for the output uplink file, 
                  default is p_pfiltr_pia.txt
       INST_TAB : string to identify the instrument table, eg P_SS_SL
       VERSION : the version number, string type, (00.00)
                 default is 00.01
       AUTHOR : author, string type, default is PHT IDT

 PROCEDURES USED:

 MODIFICATION HISTORY:
       Written by: W. M. Tai
	Oct 95 Version 3.5

(See /write_asc_pfiltr.pro)


WRITE_ASC_PPSF

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
     WRITE_ASC_PPSF
 PURPOSE:
	Write a PHT PPSF to an uplink file.
 CATEGORY:
	PIA - I/O
 CALLING SEQUENCE:
       WRITE_ASC_FCSPOW, FILENAME, PPSF_TABLE
                   INST_TAB = INST_TAB, 
                   VERSION = VERSION, AUTHOR = AUTHOR

 INPUT:
       filename: uplink file name 
       talble: ppsf table, 2 dimensional array 

 OPTIONAL INPUT:
       INST_TAB : string to identify the instrument table, eg P_FC1_C1
       VERSION : the version number, string type, (00.00)
                 default is 00.01
       AUTHOR : author, string type, default is PHT IDT

 PROCEDURES USED: 

 MODIFICATION HISTORY:
       Written by: W. M. Tai
	Oct 95 Version 3.5

(See /write_asc_ppsf.pro)


WRITE_ASC_PSSSL

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
     WRITE_ASC_PSSSL
 PURPOSE:
       Write a PHT PSSSL to an uplink file.
 CATEGORY:
	PIA - I/O
 CALLING SEQUENCE:
       WRITE_ASC_PSSSL, DET=det, PIXEL = PIXEL, FPSF = FPSF, LC = LC, 
                   TRANS = TRANS, RRESPONS = RRESPONS,
                   INPUTFILE = INPUTFILE, OUTPUTFILE = OUTPUTFILE,
                   INST_TAB = INST_TAB,
                   VERSION = VERSION, AUTHOR = AUTHOR

 INPUT:

 OPTIONAL INPUT:
       DET: string type of 'SS' or 'SL'. If det is set as keyword,
         the following four optional parameters have to be an array of
         64 elements, if not they have to contain 128 elements.
       PIXEL: individual pixel number, this override the detector value if
              set, integer
       FPSF: point spread function for pixel, floating point
       LC: Central wavelength, floating point
       TRANS: total transmission for the pixel, floating point
       RRESPONS: relative system response for pixel, floating point
       INPUTFILE: string type for the input uplink file, 
                  default is p_detect.txt
       OUTPUTFILE: string type for the output uplink file, 
                  default is p_ss_sl.txt
       INST_TAB : string to identify the instrument table, eg P_SS_SL
       VERSION : the version number, string type, (00.00)
                 default is 00.01
       AUTHOR : author, string type, default is PHT IDT

 PROCEDURES USED:

 MODIFICATION HISTORY:
       Written by: W. M. Tai
	Modified by: C Gabriel
	Oct 95 Version 3.5

(See /write_asc_psssl.pro)


WRITE_CRELIN

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
     WRITE_CRELIN
 PURPOSE:
	Write a PHT CRELIN to a FITS file.
 CATEGORY:
	PIA - I/O
 CALLING SEQUENCE:
       WRITE_CRELIN, FILENAME, DETECTOR, CRELIN_TABLE,
                   PIPELINENAME = PIPELINENAME,
                   COMMENT = COMMENT, VERSION = VERSION

 INPUT:
       filename: fits file name without the '.FITS' extension
       det: character string of 'C1', 'C2', 'P'
       talble: crelin table, 4 dimensional array of
               121 * detector pixels * 3 * 2

 OPTIONAL INPUT:
       PIPELINENAME: string type, default is the pipeline product name
       COMMENT : the comment line in the fits header, string type
       VERSION : the version number, string type, less than 8 chars
                 default is 0001

 PROCEDURES USED: 

 MODIFICATION HISTORY:
       Written by: W. M. Tai
	Modified by: C Gabriel
	Oct 95 Version 3.5
	Changing pixel order to SPD pipeline convention 
	  when writing out (CG) 			Dec.96
	V5.5

(See /write_crelin.pro)


WRITE_DARK

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
     WRITE_DARK
 PURPOSE:
	Write a PHT DARK CURRENT to a FITS file.
 CATEGORY:
	PIA - I/O
 CALLING SEQUENCE:
       WRITE_DARK, FILENAME, DARKP1, DARKP2, DARKP3, DARK1C, DARK2C, DARKS
                   COMMENT = COMMENT, VERSION = VERSION, FITS = fits

 INPUT:
       filename: fits file name without the '.FITS' extension
       darkp1, darkp2, darkp3: single float type 
       dark1c, dark2c, darks: array of float type, size of 8, 4, 128

 OPTIONAL INPUT:
       PIPELINENAME: string type, default is the pipeline product name
       COMMENT : the comment line in the fits header, string type
       VERSION : the version number, string type, less than 8 chars
                 default is 0001
	FITS: IF present and not equal 0, write out FITS file

 PROCEDURES USED: 
       Common Block(s) or @ procedure(s):
               phtdarkcur

 MODIFICATION HISTORY:
       Written by: W. M. Tai
	Modified by: C Gabriel
	Oct 95 Version 3.5

(See /write_dark.pro)


WRITE_DARKCSTR

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       WRITE_DARKCSTR
 PURPOSE:
       Append a new structure to the dark current structure corresponding 
	to det 
 CATEGORY:
	PIA - I/O
 CATEGORY:
       
 CALLED SEQUENCE:
       WRITE_DARKCSTR, DETECTOR_NAME, newdarkcstr, [,/REPLACE]
 INPUTS:
       DETECTOR_NAME: ONE OF THESE STRINGS -- P1, P2, P3, C1, C2, SL
       darkcurr: the corresponding new dark current structure
 OPTIONAL INPUTS:
       NONE
 KEYWORD PARAMETERS:
       REPLACE:  the new structure will replace the old one. If not
		  set then it will be appended
 PROCEDURE:
 MODIFICATION HISTORY:
       WRITTEN BY: Carlos GABRIEL
	Oct 95 Version 3.5
       Replace version included (Jacosta) June 96

(See /write_darkcstr.pro)


WRITE_DETDARKCUR

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
     WRITE_DETDARKCUR
 PURPOSE:
	Write a PHT-subsystem DARK CURRENT to a STRING ARRAY containing all dark
	currents (same format as PDARKCUR)
 CATEGORY:
	PIA - I/O
 CALLING SEQUENCE:
	WRITE_DETDARKCUR, det, darkcur [,fitsfile=fitsfile] 

 INPUT:
       det: PHT-subsystem
       darkcur: Dark current array corresponding to det

 OPTIONAL INPUT:
       FITSFIL : The name of the fitsfile (without extension) in case
		   that a FITS file should be written
	COMMENT : The comment line in the fits header, string type
       VERSION : the version number, string type, less than 8 chars
                 default is 0001

 PROCEDURES USED: 
       Common Block(s) or @ procedure(s):
               phtdarkcur
       PIA Procedure(s):
               get_darkcur
               write_dark
 MODIFICATION HISTORY:
       Written by: Carlos GABRIEL
	Oct 95 Version 3.5
	Swapping C2 pixels for FITS file  (CG) 	December 1996
	V5.5		

(See /write_detdarkcur.pro)


WRITE_DIETRANS

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
     WRITE_DIETRANS
 PURPOSE:
	Write a PHT DIE 1 or 2 Transfer Function to a FITS file.
 CATEGORY:
	PIA - I/O
 CALLING SEQUENCE:
       WRITE_DIETRANS, FILENAME, INSTRUMENT, PDIEFIX, PDIEUOF,PDIEGN1,PDIEGN2
                   COMMENT = COMMENT, VERSION = VERSION 

 INPUT:
       INSTRUMENT: character strings of '1', '2'
       PDIEFIX, PDIEUOF, PDIEGN1, PDIEGN2: float array
       

 OPTIONAL INPUT:
       PIPELINENAME: string type, default is the pipeline product name
       COMMENT : the comment line in the fits header, string type
       VERSION : the version number, string type, less than 8 chars
                 default is 0001

 PROCEDURES USED: 

 MODIFICATION HISTORY:
       Written by: W. M. Tai
	Modified by: C Gabriel
	Oct 95 Version 3.5

(See /write_dietrans.pro)


WRITE_FCSPOW

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
     WRITE_FCSPOW
 PURPOSE:
	Write a PHT FCSPOW to a FITS file.
 CATEGORY:
	PIA - I/O
 CALLING SEQUENCE:
       WRITE_FCSPOW, FILENAME, DETECTOR, FCSPOW_TABLE,
		    PIPELINENAME = PIPELINENAME,
                   COMMENT = COMMENT, VERSION = VERSION

 INPUT:
       filename: fits file name without the '.FITS' extension
       det: character string of 'C1', 'C2', 'P1', 'P2', 'P3'
       talble: fcspow table, 4 dimensional array of
               45 * nr of filters for det * 2 * 2

 OPTIONAL INPUT:
	PIPELINENAME: string type, default is the pipeline product name
       COMMENT : the comment line in the fits header, string type
       VERSION : the version number, string type, less than 8 chars
                 default is 0001

 PROCEDURES USED: 

 MODIFICATION HISTORY:
       Written by: W. M. Tai
	Modified by: C Gabriel
	Oct 95 Version 3.5

(See /write_fcspow.pro)


WRITE_FCSPRE_STR

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       WRITE_FCSPRE_STR
 PURPOSE:
       Append new records to the FCS Pre-reduced Signal Table corresponding 
	to det, using the keyword REPLACE it will replace the whole structure
 CATEGORY:
	PIA - I/O
 CATEGORY:
       
 CALLED SEQUENCE:
       WRITE_FCSPRE_STR, DETECTOR_NAME, newfcspre_str
 INPUTS:
       DETECTOR_NAME: ONE OF THESE STRINGS -- P1, P2, P3, C1, C2
       newfcsprestr: the corresponding new FCS Pre-reduced Signal Table
 OPTIONAL INPUTS:
       NONE
 KEYWORD PARAMETERS:
       NONE
 PROCEDURE:
 MODIFICATION HISTORY:
       WRITTEN BY: Carlos GABRIEL (ESA/VILSPA)		October 1995
	keyword replace introduced - JAcosta            June 1996

(See /write_fcspre_str.pro)


WRITE_FCSPSTR

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       WRITE_FCSPSTR
 PURPOSE:
       Append new records to the FCSP current structure corresponding 
	to det 
 CATEGORY:
	PIA - I/O
 CATEGORY:
       
 CALLED SEQUENCE:
       WRITE_FCSPSTR, DETECTOR_NAME, newfcspstr, [/REPLACE]
 INPUTS:
       DETECTOR_NAME: ONE OF THESE STRINGS -- P1, P2, P3, C1, C2
       newfcspstr: the corresponding new FCS powers structure
 OPTIONAL INPUTS:
       NONE
 KEYWORD PARAMETERS:
       NONE
 PROCEDURE:
 MODIFICATION HISTORY:
       WRITTEN BY: Carlos GABRIEL
	Oct 95 Version 3.5
	Typ name changed  CG		October 1995	
       keyword replace introduced - JAcosta            June 1996

(See /write_fcspstr.pro)


WRITE_IAAP

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       WRITE_IAAP
 PURPOSE:
	Write a PHT-AAP (Auto Analysis) measurement from the dynamical 
	structure PHTAAP onto an IDL savefile  
 CATEGORY:
	PIA - I/O
 CALLING SEQUENCE:
       WRITE_IAAP, PHTAAP_INDEX, FNAME = FNAME, PATH =PATH, INFO = INFO

 INPUT:
       PHTAAP_INDEX 	: Index of the measurement within PHTAAP

 OPTIONAL KEYWORD:
	FNAME   :  name of the save file, by default PHTSCP.ADMN is used
	PATH	:  directory where the internal file is saved

 OUTPUT:
	IDL save file

 RESTRICTIONS:
       PHTAAP(PHTSCP_INDEX) must exist

 PROCEDURES USED:
       Common Block(s) or @ procedure(s):
               phtscp

 MODIFICATION HISTORY:
       Written by: J. Acosta
	Feb. 98 Version 7.0

(See /write_iaap.pro)


WRITE_ICLA

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       WRITE_ICLA
 PURPOSE:
	Write a PHT-CLA (Calibration A) measurement from the dynamical 
	structure PHTCLA onto an IDL savefile  
 CATEGORY:
	PIA - I/O
 CALLING SEQUENCE:
       WRITE_ICLA, PHTCLA_INDEX

 INPUT:
       PHTCLA_INDEX 	: Index of the measurement within PHTCLA
 OUTPUT:
	IDL save file


 RESTRICTIONS:
       PHTCLA(PHTCLA_INDEX) must exist

 PROCEDURES USED:
       Common Block(s) or @ procedure(s):
               phtcla

 MODIFICATION HISTORY:
       Written by: C. Gabriel
	Oct 95 Version 3.5

(See /write_icla.pro)


WRITE_ILLUM

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
     WRITE_ILLUM
 PURPOSE:
	Write a PHT FCS Illumination to a FITS file.
 CATEGORY:
	PIA - I/O
 CALLING SEQUENCE:
       WRITE_ILLUM, FILENAME, INSTRUMENT, ILCOR, ILLUN,
		    PIPELINENAME = PIPELINENAME,
                   USERNAME = USERNAME, COMMENT = COMMENT, VERSION = VERSION 

 INPUT:
	FILENAME: filename for the output file without extension
       INSTRUMENT : character strings of '1' or '2'
       ILCOR, ILLUN : float array of C100 or C200 pixel size
       

 OPTIONAL INPUT:
       PIPELINENAME: string type, default is the pipeline product name
       USERNAME : the username line in the fits header, string type.
                  the maximum character length is 8.
       COMMENT : the comment line in the fits header, string type
       VERSION : the version number, string type, less than 8 chars
                 default is 0001

 PROCEDURES USED: 

 MODIFICATION HISTORY:
       Written by: W. M. Tai
	Modified by: C Gabriel
	Oct 95 Version 3.5
	Change pixel order for C200 to pipeline SPD convention (CG)  Dec.96
	V5.5

(See /write_illum.pro)


WRITE_ISCP

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       WRITE_ISCP
 PURPOSE:
	Write a PHT-SCP (Signal Data) measurement from the dynamical 
	structure PHTSCP onto an IDL savefile  
 CATEGORY:
	PIA - I/O
 CALLING SEQUENCE:
       WRITE_ISCP, PHTSCP_INDEX, FNAME = FNAME, PATH =PATH, INFO = INFO

 INPUT:
       PHTSCP_INDEX 	: Index of the measurement within PHTSRD

 OPTIONAL KEYWORD:
	FNAME   :  name of the save file, by default PHTSCP.ADMN is used
	PATH	:  directory where the internal file is saved

 OUTPUT:
	IDL save file

 RESTRICTIONS:
       PHTSCP(PHTSCP_INDEX) must exist

 PROCEDURES USED:
       Common Block(s) or @ procedure(s):
               phtscp

 MODIFICATION HISTORY:
       Written by: J. Acosta
	Apr 97 Version 6.2

(See /write_iscp.pro)


WRITE_ISRD

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       WRITE_ISRD
 PURPOSE:
	Write a PHT-SRD (Signal Data) measurement from the dynamical 
	structure PHTSRD onto an IDL savefile  
 CATEGORY:
	PIA - I/O
 CALLING SEQUENCE:
       WRITE_ISRD, PHTSRD_INDEX, FNAME = FNAME, PATH =PATH

 INPUT:
       PHTSRD_INDEX 	: Index of the measurement within PHTSRD

 OPTIONAL KEYWORD:
	FNAME   :  name of the save file, by default PHTSRD.ADMN is used
	PATH	:  directory where the internal file is saved

 OUTPUT:
	IDL save file

 RESTRICTIONS:
       PHTSRD(PHTSRD_INDEX) must exist

 PROCEDURES USED:
       Common Block(s) or @ procedure(s):
               phtsrd

 MODIFICATION HISTORY:
       Written by: C. Gabriel
	Oct 95 Version 3.5
	Modification to include options path and fname (JAcosta) 	Apr. 97

(See /write_isrd.pro)


WRITE_MAP

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
     WRITE_MAP
 PURPOSE:
       Write a PHT MAP to a FITS file.
 CATEGORY:
       PIA - I/O
 CALLING SEQUENCE:
       WRITE_MAP, FILENAME, MAP, HEADER, MAPPAR, PATH = PATH
                   COMMENT = COMMENT, VERSION = VERSION, USERNAME = USERNAME

 INPUT:
       filename: fits file name with the '.FITS' extension
	map: a N X M float array, it would accept any type of array
	hdr: fits header from the phtaap
	mappar: the parameter structure from the pia_mapw.pro

 OPTIONAL INPUT:
	PATH : the path to write the file
       COMMENT : the comment line in the fits header, string type
       VERSION : the version number, string type, less than 8 chars
                 default is 0001
       USERNAME: the username
; PROCEDURES USED:
       Common Block(s) or @ procedure(s):
               addpar2hdr
		addcomm2hdr
		get_sysdate
	Astronomical Library:
		writefits  (modified !!!)

 MODIFICATION HISTORY:
       Written by: W. M. Tai,	FEB, 1996
	Use of writefits instead of openw (Jacosta) 	April 1997
	Bug in writefits corrected (writefits -> writefits_mod) -> 
		No byte swapping in this routine (CG)	July 1998
	BUNIT=JY/BEAM for maps in Jy 
 V7.3

(See /write_map.pro)


WRITE_PPSF

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
     WRITE_PPSF
 PURPOSE:
	Write a PHT Point Spread Function Corrections to a FITS file.
 CATEGORY:
	PIA - I/O
 CALLING SEQUENCE:
       WRITE_PPSF, FILENAME, PPSF_TABLE, PIPELINENAME = PIPELINENAME
                   COMMENT = COMMENT, VERSION = VERSION

 INPUT:
       filename: fits file name without the '.FITS' extension
       talble: ppsf table, 2 dimensional array of
               15 * 14

 OPTIONAL INPUT:
       PIPELINENAME: string type, default is the pipeline product name
       COMMENT : the comment line in the fits header, string type
       VERSION : the version number, string type, less than 8 chars
                 default is 0001

 PROCEDURES USED: 

 MODIFICATION HISTORY:
       Written by: W. M. Tai
	Modified by: C Gabriel
	Oct 95 Version 3.5

(See /write_ppsf.pro)


WRITE_RESP

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
     WRITE_RESP
 PURPOSE:
	Write a PHT responsivities to a FITS file.
 CATEGORY:
	PIA - I/O
 CALLING SEQUENCE:
       WRITE_RESP, FILENAME, P2RESP, P2RESP, P3RESP, C1RESP, C2RESP, SRESP,
		    PIPELINENAME = PIPELINENAME,
                   COMMENT = COMMENT, VERSION = VERSION

 INPUT:
       filename: fits file name without the '.FITS' extension
       p1resp, p2resp, p3resp: single double type 
       c1resp, c2resp, sresp: array of double type, size of 8, 4, 128

 OPTIONAL INPUT:
       PIPELINENAME: string type, default is the pipeline product name
       COMMENT : the comment line in the fits header, string type
       VERSION : the version number, string type, less than 8 chars
                 default is 0001

 PROCEDURES USED: 

 MODIFICATION HISTORY:
       Written by: W. M. Tai
	Modified by: C Gabriel
	Oct 95 Version 3.5
	to pipeline SPD C200 pixel order + PHT-S out (CG)	December 1996
	V5.5

(See /write_resp.pro)


WRITE_RESPSTR

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       WRITE_RESPSTR
 PURPOSE:
       Append new records to the RESP current structure corresponding 
	to det 
 CATEGORY:
	PIA - I/O
 CATEGORY:
       
 CALLED SEQUENCE:
       WRITE_RESPSTR, DETECTOR_NAME, newrespstr
 INPUTS:
       DETECTOR_NAME: ONE OF THESE STRINGS -- P1, P2, P3, C1, C2
       newrespstr: the corresponding new FCS powers structure
 OPTIONAL INPUTS:
       NONE
 KEYWORD PARAMETERS:
       REPLACE: replace RESP structure through new records
 PROCEDURE:
 MODIFICATION HISTORY:
       WRITTEN BY: Carlos GABRIEL
       Modified by: Wai-Ming Tai
	Oct 95 Version 3.5
	Replacing of old structure possible (CG)	January 1996

(See /write_respstr.pro)


WRITE_SCP

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
     WRITE_SCP
 PURPOSE:
	Write a PHT-SCP (Signal Per Chopper Plat.) measurement from a temporary 
	structure PHTSCP onto a fits file
 CATEGORY:
	PIA - I/O
 CALLING SEQUENCE:
       WRITE_SCP, TMPDATA[, tmphdr]

 INPUT:
       tmpdata	: PHTSCP structure
       filename: filename to store the fitsfile

 OPTIONAL INPUT:
       tmphdr	: PHTSCP header 


 RESTRICTIONS:
       tmpdata must be a valid PHTSCP structure

 PROCEDURES USED: 
       Common Block(s) or @ procedure(s):
               phtscp
	Astronomical Library:
		size_struct

 MODIFICATION HISTORY:
       Written by: W. M. Tai
	Modified (last) by: C Gabriel			November 1996
	V5.x
	Y2K Compliance (CG)		Jun 1999
	V7.4

(See /write_scp.pro)


WRITE_SELNDR

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
     WRITE_SELNDR
 PURPOSE:
	Write a PHT SELNDR to a FITS file.
 CATEGORY:
	PIA - I/O
 CALLING SEQUENCE:
       WRITE_SELNDR, FILENAME, PP1SNDR, PP2SNDR, PP3SNDR,  
                   PC1SNDR, PC2SNDR, PSSSNDR, PSLSNDR, DRFLAG,
		    PIPELINENAME = PIPELINENAME,
                   USERNAME = USERNAME, COMMENT = COMMENT, VERSION = VERSION 

 INPUT:
       PP1SNDR, PP2SNDR, PP3SNDR: Long interger array
       PC1SNDR, PC2SNDR, PSSSNDR, PSLSNDR: Long interger array

 OPTIONAL INPUT:
       DRFLAG: integer
	PIPELINENAME: string type, default is the pipeline product name
       USERNAME : the username line in the fits header, string type
       COMMENT : the comment line in the fits header, string type
       VERSION : the version number, string type, less than 8 chars
                 default is 0001

 PROCEDURES USED: 

 MODIFICATION HISTORY:
       Written by: W. M. Tai
	Modified by: C Gabriel
	Oct 95 Version 3.5

(See /write_selndr.pro)


WRITE_SPD

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
     WRITE_SPD
 PURPOSE:
	Write a PHT-SPD (Standard Processed Data) measurement from a temporary 
	structure PHTSPD onto a fits file
 CATEGORY:
	PIA - I/O
 CALLING SEQUENCE:
       WRITE_SPD, TMPDATA[, tmphdr]

 INPUT:
       tmpdata	: PHTSPD structure
 
 OPTIONAL INPUT:
	tmphdr	: PHTSPD header
       filename: filename to store the fitsfile

 RESTRICTIONS:
       tmpdata must be a valid PHTSPD structure

 PROCEDURES USED: 
       Common Block(s) or @ procedure(s):
               phtspd

 MODIFICATION HISTORY:
       Written by: W. M. Tai
	Modified (last) by: C Gabriel			November 1996
	V5.x
	mod SPD_UNIT line to make sure the unit is
	19 chars long         WMT                       Feb 1997
	Bug for P-raster mode fixed +
	 bug for keywords TFORM fixed  (CG)		Oct 1997
	V6.5
	Bug for SL case (wrong position of ') fixed (CG) May 1998
	V7.2
	Y2K Compliance (CG)		Jun 1999
	V7.4

(See /write_spd.pro)


WRITE_SRD

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
     WRITE_SRD
 PURPOSE:
	Write a PHT-SRD (Signal Data) measurement from a temporary 
	structure PHTSRD onto a fits file
 CATEGORY:
	PIA - I/O
 CALLING SEQUENCE:
       WRITE_SRD, TMPDATA

 INPUT:
       tmpdata	: PHTSRD structure

 OPTIONAL INPUT:
       tmphdr	: A temporary header
       filename: filename to store the fitsfile


 RESTRICTIONS:
       tmpdata must be a valid PHTSRD structure

 PROCEDURES USED: 
       Common Block(s) or @ procedure(s):
               phtsrd

 MODIFICATION HISTORY:
       Written by: W. M. Tai
	Modified by: C Gabriel
	Oct 95 Version 3.5
	Extension for effective reset time and nr of read-outs (CG)	Jan.96
	trim to srd_unit to 18 chars    (WMT)            March 96
	Storing into PIA_SAVEDIR 	(CG)		 March 96
	filename keyword added          (WMT)            Apr   96
	No byteswap to flag (CG)			 August96

	Y2K Compliance (CG)				 Jun 1999
	V7.4
	Bug for array data fixed (CG)			 March 2000 
	V8.2

(See /write_srd.pro)


WRITE_SUBTR

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       WRITE_SUBTR
 PURPOSE:
	WRITES source - background subtracted values from srcsubt accomodating 
	them into the dynamical structure PHTSCP or PHTSPD (ispd=1)  
 CATEGORY:
	PIA - I/O
 CALLING SEQUENCE:
       WRITE_SUBTR, srcsubt, data, ispd, newhdr, no_info=no_info,  $
              OUTMEAS=outmeas 

 INPUT:
       srcsubt:
		A structure containing the subtracted values
	data:
		The PHTSCP or PHTSPD temporary structure used for the
		subtraction
	ispd:
		0 for SCP, 1 for SPD, 2 for AAP

 OPTIONAL INPUT:
	NEWHDR:	
		Modified header to be used as input in the new structure, it
		will be modified in the output 

 KEYWORDS:
	NO_INFO:
		Suppressing message 
	OUTMEAS:
		subtracted SCP (SPD) temporary structure
	NO_INTO_BUFFER:
		do not put the measurement into the corresponding buffer

 PROCEDURES USED:
       Common Block(s) or @ procedure(s):
               adm
               phtscp
               phtspd

 MODIFICATION HISTORY:
       Written by: C. Gabriel (ESA/VILSPA-SAI)		December 1995
	Extension for ARSI, ANDR and AVSD (CG)		January 1996
	Information added on buffer name (CG)		April 1996
	NO_INFO keyword added (CG)			July 1996
	Added outmeas keyword to provide the 
	resulting subtracted structure  (JA+CG)		May 1997
	Added REDUCE_MED keyword to reduce subtracted 
	signals to one value using median   (JA)	Aug 1997
	Keyword NO_INTO_BUFFER added (CG)		Oct 1997
	V6.5
	Chopper position from source instead from 
	background (CG)					Oct 1997
	V6.6
 	Bug in HDR keyword for SCP case fixed (CG)	Jan 1998
	V7.0
	Bug in SCP & NO_INTO_BUFFER fixed (CG)		Mar 1998
	V7.1
	Bug for 1 element case fixed (CG)		Mar 1999
	V7.4

(See /write_subtr.pro)


WRITE_VIGN

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
     WRITE_VIGN
 PURPOSE:
	Write a PHT VIGNETTING Corrections to a FITS file.
 CATEGORY:
	PIA - I/O
 CALLING SEQUENCE:
       WRITE_VIGN, FILENAME, DETECTOR, VIGN_TABLE,
		    PIPELINENAME = PIPELINENAME,
                   COMMENT = COMMENT, VERSION = VERSION

 INPUT:
       filename: fits file name without the '.FITS' extension
       det: character string of 'C1', 'C2', 'P1', 'P2', 'P3'
       talble: vignet table, 3 dimensional array of
               detector pixels * 25 * filters

 OPTIONAL INPUT:
       PIPELINENAME: string type, default is the pipeline product name
       COMMENT : the comment line in the fits header, string type
       VERSION : the version number, string type, less than 8 chars
                 default is 0001

 PROCEDURES USED: 

 MODIFICATION HISTORY:
       Written by: W. M. Tai
	Modified by: C Gabriel
	Oct 95 Version 3.5
	Change according to pipeline SPD C200 pixel order - CG	December 1996

(See /write_vign.pro)


XDISP_HK

[Previous Routine] [List of Routines]
 NAME:
       xdisp_hk
 PURPOSE:
       Display hk status and analog data depending on the time.
 CATEGORY:
	PIA - graphics

 CALLING SEQUENCE:
        xdisp_hk

 INPUT PARAMETERS:
        NONE

 OUTPUT PARAMETERS:
       NONE

 RESTRICTIONS:
       NONE
 
 METHOD:
       Check, if the data is status or analog. Print status data in a
       table and analog data in a curve, both in relation with the time        

 PROCEDURES USED:
       Common Block(s) or @ procedure(s):
               colour_indices
               phthk
               phthk
       PIA Procedure(s):
               get_boundaries
               pia_xplot

 MODIFICATION HISTORY:
       Written by: Andreas Karch
	Oct 95 Version 3.5
	Overplot with same axis capability added (CG)	April 1997
	V6.2

(See /xdisp_hk.pro)