Headers for LASCO IDL Library: REDUCE

This page was created by IDL lasco_mk_html_help.pro on Wed Aug 17 12:22:01 2005.


List of Routines


Routine Descriptions

B32TOINT

[List of Routines] (See ./mb2str/b32toint.pro)

 PROJET
     SOHO-LASCO

 NAME:
  B32TOINT

 PURPOSE:
  Convert a base 32 number to integer

 CATEGORY:
  Mathematics

 CALLING SEQUENCE:
   
 DESCRIPTION:

 INPUTS:

 INPUT KEYWORD:

 OUTPUTS:

 PROCEDURE:
  
 CALLED ROUTINES:

 HISTORY:
	V1 A.Thernisien 10/07/2001
 CVSLOG:
  $Log: b32toint.pro,v $
  Revision 1.2  2002/07/11 07:24:12  arnaud
  Insertion of the Log in each header



BUILD_C3_BACK.PRO

[List of Routines] (See ./las_c3/build_c3_back.pro)

 PROJET:
     SOHO-LASCO

 NAME:
     build_c3_back.pro

 PURPOSE
    build a edge image (i.e. a planar image) varying in y for C3 background correction

 INPUT
    c3mask           mask of useful pixels of c3 images

 KEYWORD INPUT: 
    ROI=roi          defines a specific area of CCD ( define it in
                     the same unit than c3mask pixel coordinates)
                     [x1,y1,x2,y2]
    XY={0,1}         To build two edges (in X and Y)

 OUTPUT:
    c3back_y         planar image varying in y (slope = 1 per pixel)
    c3back_x         planar image varying in x (slope = 1 per pixel)
 RESTRICTIONS
    initial image must be square


C2_CALFACTOR

[List of Routines] (See ./c2_calfactor.pro)

NAME:
	C2_CALFACTOR

PURPOSE:
	This function returns the calibration factor for a given C2 image

CATEGORY:
	REDUCE

CALLING SEQUENCE:
	result = C2_CALFACTOR(Header)

INPUT:	
	Header:	image header, either fits or lasco structure

 Keywords:
	NOSUM	If set, do not correct for summing

OUTPUT:
	Image calibration factor in (B/Bsun)/(DN/pixel-second)

PROCEDURE:

	Same as C3_CALFACTOR.pro
	the output is automatically scaled for pixel summing

 MODIFICATION HISTORY:
	Written Clarence Korendyke, NRL
       Added C2/C3 Orange ratio as c2c3match - DW 07/09/99

	NBR Nov  7 2001 - Change Version to use SCCS version; change header HISTORY
	NBR Mar 11 2003 - Add /NOSUM

 SCCS variables for IDL and Header use
 
er= '@(#)c2_calfactor.pro	1.5, 03/14/03' ;NRL LASCO IDL LIBRARY



C2_CALIBRATE

[List of Routines] (See ./c2_calibrate.pro)

 NAME:
	C2_CALIBRATE

 PURPOSE:
	This function calibrates a C2 image to mean solar brightness units

 CATEGORY:
	REDUCE

 CALLING SEQUENCE:
	Result = C2_CALIBRATE(Img,Header)

 INPUTS:
	Img:	A 2-D image array in units of DN
	Header:	An image header (FITS or LASCO header structure)

 OUTPUTS:
	The calibrated image is returned.  The units are mean solar 
	brightness. The header is also modified.

 KEYWORDS:
	NEW	Force read of calib arrays
	NO_UPDATE	Do not use log files and force read of calib arrays
	NO_CALFAC	Do not apply calibration factor (set = 1d)

 COMMON BLOCKS:
	C2_CAL_IMG, DBMS

 RESTRICTIONS:
	Only handles clear polarizer except for H-alpha
	Must have LASCO IDL Library
	Must have environment $LASCO_DATA defined

 PROCEDURE:
	The routine reads in the vignetting and a mask array from the
	$LASCO_DATA/calib directory.  To obtain the calibration
	factors, it calls the C2_CALFACTOR procedure.

 MODIFICATION HISTORY:
 	Written by: Ed Esfandiari  April 08, 1999	
       V1  aee  Apr 08, 99 First version (based on c3_calibrate). 
       V2  dw   Sep 18, 99 Added no_calfac keyword (apply summing and vignetting only)
       V3  aee  Apr 25, 00 Removed !Version.os eq 'OSF' statement. It is not needed since
                           C2 vignetting is a .fts file which is machine independent.
	nbr Nov  7 2001 - Add-ons for reduce_level_1: add HISTORY comments in header; use 
			$LASCO_DATA; use SCCS version
	nbr Jun 25 2002 - Update get_cal_name argument
	nbr Mar 10 2003 - Add functionality for non-PB summed images
	nbr May 14 2003 - Remove errant stop
	nbr Aug 20 2003 - Name vig file explicitly


 Variables for SCCS and FITS header 

er= '@(#)c2_calibrate.pro	1.10, 09/08/03' ;NRL LASCO IDL LIBRARY

      


C3_CALFACTOR[1]

[List of Routines] (See ./c3_calfactor.pro)

NAME:
	C3_CALFACTOR

PURPOSE:
	This function returns the calibration factor for a given C3 image

CATEGORY:
	REDUCE

CALLING SEQUENCE:
	result = C3_CALFACTOR(Header)

INPUT:	
	Header:	image header, either fits or lasco structure

Keywords:
	NOSUM	If set, do not correct for summing

OUTPUT:
	Image calibration factor in (B/Bsun)/(DN/pixel-second)

PROCEDURE:

  The document describes the C3 calibration factor derived from the laboratory
  images taken in April 1994.
  The calibration factor is in 10^-10 (B/Bsun)/(DN/pixel-second).
  The units of the image to be multiplied need to be DN/pixel-second.
  The calibration factor is then scaled appropriately for pixel summation.

  Additional work will be required to remove a number of other factors.
  The calibration factor numbers need the port amplifier
  effect removed; color effects removed (IR filter affected greatly) and a
  number of other corrections.  The photometric effect of pixel summation will
  have to be examined.

  preliminary calibration factors for C3 (3/17/96):

  filter	polarizer	calibration factor
  			        (10^-10B/Bsun)/(DN/pixel-second)

  clear	clear		0.00503			
  blue		clear		0.1033
  orange	clear		0.0286
  deep red	clear		0.01937
  infrared	clear		0.1055  
  clear 	Halpha		1.541

  These were evaluated with the flat field response set to 1.0 at 20Rsun
  altitude.  Areas of the field inside and outside 20Rsun will be somewhat
  effected by the flat field calibration (+/- 10-15%).

	the output is automatically scaled for pixel summing

 MODIFICATION HISTORY:
	Written Clarence Korendyke, NRL
	V1	3/15/96	CMK	raw calibration factors computed with tabulated exposure durations
	V2	3/17/96	CMK	calibration factor corrected for exp cmd and exp duration and exp2
	V3	6/13/98	RAH	modified to allow polarizer coeffs to be different for each filter
				updated coeffs for latest values, obtained from calibration window
				ratios with door closed
	7/19/00 NBR	Change Version to use SCCS version; change header HISTORY
	1/19/01 NBR	Change clear-clear factor to match above comments
	3/11/03 NBR	Add /NOSUM
       6/8/05  RAH     Add time variable calibration coefficient
       6/22/05 Karl B  Small bug fix.

 SCCS variables for IDL use
 
er= '@(#)c3_calfactor.pro	1.13 06/22/05' ;LASCO IDL LIBRARY



C3_CALFACTOR[2]

[List of Routines] (See ./c3_calfactor_var.pro)

NAME:
	C3_CALFACTOR

PURPOSE:
	This function returns the calibration factor for a given C3 image

CATEGORY:
	REDUCE

CALLING SEQUENCE:
	result = C3_CALFACTOR(Header)

INPUT:	
	Header:	image header, either fits or lasco structure

Keywords:
	NOSUM	If set, do not correct for summing

OUTPUT:
	Image calibration factor in (B/Bsun)/(DN/pixel-second)

PROCEDURE:

  The document describes the C3 calibration factor derived from the laboratory
  images taken in April 1994.
  The calibration factor is in 10^-10 (B/Bsun)/(DN/pixel-second).
  The units of the image to be multiplied need to be DN/pixel-second.
  The calibration factor is then scaled appropriately for pixel summation.

  Additional work will be required to remove a number of other factors.
  The calibration factor numbers need the port amplifier
  effect removed; color effects removed (IR filter affected greatly) and a
  number of other corrections.  The photometric effect of pixel summation will
  have to be examined.

  preliminary calibration factors for C3 (3/17/96):

  filter	polarizer	calibration factor
  			        (10^-10B/Bsun)/(DN/pixel-second)

  clear	clear		0.00503			
  blue		clear		0.1033
  orange	clear		0.0286
  deep red	clear		0.01937
  infrared	clear		0.1055  
  clear 	Halpha		1.541

  These were evaluated with the flat field response set to 1.0 at 20Rsun
  altitude.  Areas of the field inside and outside 20Rsun will be somewhat
  effected by the flat field calibration (+/- 10-15%).

	the output is automatically scaled for pixel summing

 MODIFICATION HISTORY:
	Written Clarence Korendyke, NRL
	V1	3/15/96	CMK	raw calibration factors computed with tabulated exposure durations
	V2	3/17/96	CMK	calibration factor corrected for exp cmd and exp duration and exp2
	V3	6/13/98	RAH	modified to allow polarizer coeffs to be different for each filter
				updated coeffs for latest values, obtained from calibration window
				ratios with door closed
	7/19/00 NBR	Change Version to use SCCS version; change header HISTORY
	1/19/01 NBR	Change clear-clear factor to match above comments
	3/11/03 NBR	Add /NOSUM
       6/8/05  RAH     Add time variable calibration coefficient

 SCCS variables for IDL use
 
er= '@(#)c3_calfactor.pro	1.12 06/08/05' ;LASCO IDL LIBRARY



C3_CALIBRATE

[List of Routines] (See ./c3_calibrate.pro)

 NAME:
	C3_CALIBRATE

 PURPOSE:
	This function calibrates a C3 image to mean solar brightness units

 CATEGORY:
	REDUCE

 CALLING SEQUENCE:
	Result = C3_CALIBRATE(Img,Header)

 INPUTS:
	Img:	A 2-D image array in units of DN
	Header:	An image header (FITS or LASCO header structure)

 OUTPUTS:
	The calibrated image is returned.  The units are mean solar 
	brightness. The header is also modified.

 KEYWORDS:
	NO_VIG	Do not apply vignetting correction or pylon mask (set = 1.)
	NO_MASK Do not apply pylon/occulter mask to vig correction
	FUZZY	Interpolate gaps with fuzzy logic procedure
	NEW	Force read of calib arrays
	NO_UPDATE	Do not use log files and force read of calib arrays
	NO_CALFAC	Do not apply calibration factor (set = 1d)

 COMMON BLOCKS:
	C3_CAL_IMG, DBMS

 RESTRICTIONS:
	Only handles clear polarizer except for H-alpha

 PROCEDURE:
	The routine reads in the vignetting and a mask array from the
	$LASCO_DATA/calib directory.  To obtain the calibration
	factors, it calls the C3_CALFACTOR procedure.

 MODIFICATION HISTORY:
 	Written by:	RA Howard, 4/96
       V1  rah Apr 04 96 First version.
       V2  aee Sep 30 97 Added exposure factor and header updates.
       V3  rah Oct 31 97 Call to READ_EXP_FACTOR changed to GET_EXP_FACTOR
       V4  rah Nov 07 97 reference to FILEORIG changed to use DATE_OBS
       V5  dw  Sep 10 98 Added more polariz id flags beside PB
       V6  dab Nov 25 98 Added SWAP_ENDIAN for OSF operating systems
       V7  dw  Feb 10 99 Changed from IMG_SUM_2x2 to rebin for summed images
       V8  av  Mar 17 99 Added SL ramp correction
       V9  dw  Mar 28 99 changed SL ramp correction to ramp_fn(0)
       V9a rh  Apr  9 99 changed ramp to ramp_full in common
       V10 aee Apr 09 99 Added no_update keyword (used in image_profiles).
       V11 dw  Apr 09 99 Added no_calfac keyword (apply summing and vignetting only)
	nbr Jul 12 2000 - Change version init, header update
	nbr Jul 27 2000 - Apply ramp before vignetting correction 
	nbr Aug  4 2000 - CD to calib directory instead of using full path; 
			edit HISTORY in header
	nbr Aug  7 2000 - Change call to GET_EXP_FACTOR
	nbr Oct  2 2000 - Add FUZZY, NO_VIG keywords
	nbr Oct 25 2000 - Use READFITS to read vig and mask arrays
	nbr Jan 18 2000 - Change vig to vig_full in common block
	nbr Jan 24 2001 - Add bkg, mask_blocks to common block
	nbr Nov  6 2001 - Subtract ramp AFTER vignetting correction and add better 
			documentation; different order; do not apply
			mask to ramp
       av  Nov 20 2001 - Input image is now returned unchanged.
	nbr Jun 25 2002 - Update get_cal_name argument
	nbr Jul  5 2002 - Change bkg used for fuzzy_image
	nbr Mar 10 2003 - Add functionality for sub-fields and non-PB summed images;
			  define mask even if NO_MASK is set; only one vig and one mask
	nbr Apr 10 2003 - Change bkg and order of operations around fuzzy_image
	nbr Aug 20 2003 - Name vig and mask files explicitly
	nbr Sep  8 2003 - Comment changes, use A.Thernisien vignetting
	nbr Nov  5 2003 - Use inverted A.Thernisien vignetting        
	nbr Nov  6 2003 - Use expanded A.Thernisien vignetting       
	nbr Nov  7 2003 - Fix mask application 
	nbr Jan  2 2004 - Update mask
       nbr Apr  2 2004 - Remove comment about fuzzy_image; new mask
	nbr Apr  8 2004 - New mask
   K.Battams 6/22/2005 - Another new A.Thernisien vignetting function...
                         This time there are two for pre- and post- interruption.
   K.Battams 7/28/2005 - New vig function (previous function shifted half-pixel left)
                       - New C3 cl mask (very slightly larger)

 Variables for SCCS and FITS header 

er= '@(#)c3_calibrate.pro	1.51, 08/01/05' ; NRL LASCO IDL LIBRARY

      


CALC_DARK_BIAS

[List of Routines] (See ./calc_dark_bias.pro)

 NAME:
	CALC_DARK_BIAS

 PURPOSE:
	This procedure calculates minimum, mean, average and std dev of dark images

 CATEGORY:
	LASCO REDUCE

 CALLING SEQUENCE:
	CALC_DARK_BIAS,Files

 INPUTS:
	Files:	If optional parameter, h, not present: String array of the file names to process
		If optional parameter, h, is present: image data array

 OPTIONAL INPUTS:
	H:	Lasco header structure corresponding to image data in Files
	
 OUTPUTS:
	Write information to file in $NRL_LIB/lasco/data/bias

 PROCEDURE:
	Cacluates the average, standeard deviation, minimum (non-zero) value and the median
	value.  Also gets the current value for the offset bias.  Then appends the information
	to the file dark_bias_cX.dat, where X is the telescope number.

 EXAMPLE:
	For only one parameter, the input parameter is a list of files

		f = wlister()
		CALC_DARK_BIAS,f

	For two parameters, pass the image and the header:
		a = LASCO_READFITS(f,h)
		CALC_DARK_BIAS,a,h

 MODIFICATION HISTORY:
 	Written by:	RA Howard, 6/12/98

	@(#)calc_dark_bias.pro	1.1 04/09/99 LASCO IDL LIBRARY


CALIB_C3_SQIMA.PRO

[List of Routines] (See ./las_c3/calib_c3_sqima.pro)

 PROJET:
     SOHO-LASCO

 NAME:
     calib_c3_sqima.pro

 PURPOSE:
    Prepare a clean C3 image (image must be square)

 USE:
    calib_c3_sqima,imain,bias,exptime,imacorr,irebin,izero,nzero,c3msk,coef,jpix,prfle_xy,bkgd, $
                   IPIXN=ipixn, JPIXN=jpixn, IPOS=ipos, THRESH=thresh, vig_c3=vig_c3

 INPUT:
    imain          image get from a readfits(name,hdr) for instance
    bias           bias value
    exptime        time exposure
    irebin         rebin level          :  1 1024x1024; 2 512x512; 3 256x256
    leb_rebin      rebin level from LEB

 KEYWORD INPUT:
    THRESH=thresh  treshold to add (default = 0.)
    VIG_C3=vig_c3  vignetting correction array

 OUTPUT:
    imacorr        corrected image (background gradient and photometry)
    izero          list of zero values (from not transmited blocks)
    nzero          number of zero values
    c3msk          mask of values for C3

 KEYWORD OUTPUT:
    IPIXN=ipixn    for verification of get_c3_bkgd (debug purposes)
    JPIXN=jpixn    for verification of get_c3_bkgd
    IPOS=ipos      for verification of get_c3_bkgd

 RESTRICTIONS:
    works only with square images

 MODIFICATIONS:
	nbr, 11/30/00 - Compute vig_c3 separately before multiplying


CHECK_OBESUMERROR

[List of Routines] (See ./check_obesumerror.pro)

 NAME:
	CHECK_OBESUMERROR

 PURPOSE:
	Checks for OBE error when doing LEB summing

 CATEGORY:
	Reduce

 CALLING SEQUENCE:
	CHECK_OBESUMERROR,A,Hdr

 INPUTS:
	A:	Image to be checked
	Hdr:	FITS Header 

 KEYWORD PARAMETERS:
	FIXIT:	If present, fixes the LEBXSUM and LEBYSUM keywords

 PROCEDURE:
	An error was discovered in OBE beginning 6 March 1997.
	It started after sending a command to sum difference in EIT images.
 	The result was that the LEB summing parameter in the header was not
  	being set to the proper value.  It always read 1, even though the
  	summing was performed.

 MODIFICATION HISTORY:
	RA Howard, NRL, 24 March 97

	@(#)check_obesumerror.pro	1.1 05/14/97 LASCO IDL LIBRARY


CORR_EDGES.PRO

[List of Routines] (See ./las_c3/corr_edges.pro)

 PROJET:
    SOHO - LASCO
 NAME:
    corr_edges.pro
 PURPOSE:
    Correct edges of lasco frames
 CATEGORY:
    Instrumental correction tools, medium level routines,
 CALLING SEQUENCE:
    corr_edges, ima, iop, ideep [,/X] [,/Y]
 INPUTS:
         ima                    image array
         iop                    side to correct
                                iop=0 nothing
                                iop=1 upper side
                                   =2 lower sise
                                   =3 both
         ideep                  nb of contiguity lines to
                                   correct
 OPTIONAL INPUT PARAMETERS:
         None
 KEYWORD PARAMETERS:
         X                      border columns correction
         Y                      border lines correction
 OUTPUTS:
         ima                             corrected image array
 OPTIONAL OUTPUT PARAMETERS:
         None
 COMMON BLOCKS:
         None
 SIDE EFFECTS:
         inmput is modified
 RESTRICTIONS:
 PROCEDURE:
 MODIFICATION HISTORY:
         Written by ALL 05/14/96

 SCCS variables for IDL use

 @(#)corr_edges.pro  1.0 25/01/95 :LAS


DCT

[List of Routines] (See ./fuzzy/dct.pro)

 NAME:
	DCT

 PURPOSE:
	Computes the D.C.T. or the Inverse D.C.T.

 PROCEDURE:
	Computes the D.C.T. (Discrete Cosine Transform) or the I.D.C.T.
	(Inverse D.C.T.) of a 1D or 2D array
	The D.C.T. values here are deduced from the F.F.T. values

 CATEGORY:
	Transformation

 CALLING SEQUENCE:
	c = dct(x [, direction] )

 INPUTS:
	array		a 1D or 2D array

 Optional INPUTS:
	direction	Direction of the transform :
			By convention a negative direction means a forward
			transform, and positive means a inverse transform; 
			By default, the forward transform is performed

 KEYWORD PARAMETERS:
	INVERSE		perform the inverse transform, reguardless of the value
			of the direction parameters

 OUTPUTS:
	the DCT spectrum, with the same dimentions as the input array x

 REFERENCE:
	DIGITAL IMAGE PROCESSING ALGORITHM
	Ioannis Pitas
	Prentice Hall, (c) 1993
	(p107-108 for 1D DFT to DCT transform)
	(p111,113 for 2D DFT to DCT transform)

	See also the IDL documentation about the FFT function

 MODIFICATION HISTORY:
	Written by J. More, November 1996


DDISTIM2ECS

[List of Routines] (See ./ddistim2ecs.pro)

 NAME:				DDISTIM2ECS

 PURPOSE:			Convert date and times generated by DDIS into 
				ECS format

 CATEGORY:			REDUCTION

 CALLING SEQUENCE:		Result = DDISTIM2ECS (In)

 INPUTS:			In = date and time string in the format 
						YYMMDD_HHMMSS
					or      YYYYMMDD_HHMMSS

 OUTPUTS:			Result = a string in the ECS format:
					YY/MM/DD HH:MM:SS or YYYY/MM/DD HH:MM:SS


 RESTRICTIONS:			Only works on single strings

 PROCEDURE:			Straightforward string parsing

 MODIFICATION HISTORY:         Written    RA Howard  NRL   15 November 1995

 VERSION:			1	Initial Release

       @(#)ddistim2ecs.pro	1.1 04 Apr 1996 LASCO IDL LIBRARY


DECODE_SC_DACS

[List of Routines] (See ./decode_sc_dacs.pro)

 NAME:				DECODE_ALL_SCIENCE

 PURPOSE:			Main program to decode all science TM files
				from DACS, ECS, or Level-0 into raw DDIS files

 CATEGORY:			REDUCTION

 CALLING SEQUENCE:		DECODE_ALL_SCIENCE, Date

 INPUTS:			None

 OPTIONAL INPUTS:		Date = Date to be processed, YYMMDD
				       If date is not present, then all
				       science files in $LEB_IMG will be 
				       processed.
	
 KEYWORD PARAMETERS:		None

 OUTPUTS:			None

 OPTIONAL OUTPUTS:		None

 COMMON BLOCKS:		decode_science

 SIDE EFFECTS:

 RESTRICTIONS:

 PROCEDURE:

 EXAMPLE:

 MODIFICATION HISTORY:		Written  RA Howard, NRL
    Version 1   RAH, 21 Dec 1995,    Initial Release

       @(#)decode_sc_dacs.pro	1.1 04 Apr 1996 LASCO IDL LIBRARY


DIFF2TIME

[List of Routines] (See ./diff2time.pro)

 NAME:				DIFF2TIME

 PURPOSE:			Compares two times 

 CATEGORY:			REDUCTION			

 CALLING SEQUENCE:		Result = DIFF2TIME (Time1, Time2)

 INPUTS:			Time1 = First time as CDS time structure
				Time2 = Second time as CDS time structure

 OUTPUTS:			Result = Result of comparison:
					-1 if Time1 > Time2
					 0 if Time1 = Time2
					+1 if Time1 < Time2

 MODIFICATION HISTORY:

       @(#)diff2time.pro	1.1 04 Apr 1996 LASCO IDL LIBRARY


FIND_MISS_BLOCKS

[List of Routines] (See ./mb2str/find_miss_blocks.pro)

 PROJET:
	SOHO - LASCO

 NAME:
	FIND_MISS_BLOCKS

 PURPOSE:
	Finds all the missing blocks on an image. Generate the map of the non usefull blocks and the missing blocks.

	Call this routine before using a chain of correction, otherwise the location of all missing blocks would be lost after the 1st correction

 CATEGORY:
  missing blocks

 CALLING SEQUENCE:
	find_miss_blocks,ima,hdr,missblock,imafuzz,hdrfuzz,/fuzzyima

 ADMITTED INPUT TYPE OF IMAGES:
	all

 INPUTS:
	ima : the image to make the map
	hdr : fits header of the image

 OUTPUTS:

	missblock : output structure for fits table
		FILENAME : filename of the image
		NBMISS : number of missing blocks
		NBNUSEF : number of non usefull blocks
		MBMAP : map of the missing blocks
			1: block OK
			0: non transmitted usefull block
			-1: non usefull block
		MBMAPALL : map of all the non transmited blocks (lost plus non useful)
			1: block OK
			0: non transmitted useful or non usefull block
			note that if a block is set to -1 in MBMAP and also set to 1 in MBMAPALL it means that, even so, this block was transmitted

 OPTIONAL OUTPUTS:
	imafuzz : image with the corrected blocks
	hdrfuzz : header of the corrected image: the HISTORY specify that the image was corrected by fuzzy_image procedure

 KEYWORD INPUT:
	fuzzyima : compute the missing block interpolation by fuzzy_image procedure
       hdrstru : header structure given by getl05hdrstru
       full : resample output maps to 32*32 
       strmap : string map for the DB 

 CALLED ROUTINES:
	SXPAR.GETTOK.GET_TMASK.FUZZY_IMAGE.GET_MISS_BLOCKS.GET_TMASK_F.WHERE2D.HCIE_ZONE.READ_ZONE.GRAD_ZONE.REVERSE.SPLINE.TRI_SURF.WRITE_ZONE.FUZZY_BLOCK.READ_BLOCK.DCT.NUM_TO_FUZZY.INTER_FUZZY.FUZZY_TO_NUM.WRITE_BLOCK.SXADDPAR.

 MODIFICATION HISTORY:
	V1.0 Writen by A.Thernisien on 23/12/99 from get_miss_blocks.pro by J.MORE, September 1996
	V2.0 by A.T. 18/01/2000
       V2.1 by AT 18/09/2001 add of STRMAP and FULL keywords
 CVSLOG:
  $Log: find_miss_blocks.pro,v $
  Revision 1.2  2002/07/11 07:24:17  arnaud
  Insertion of the Log in each header



FIX_OBESUMERROR

[List of Routines] (See ./fix_obesumerror.pro)

 NAME:
	FIX_OBESUMERROR

 PURPOSE:
	Fix an OBE error encountered when doing LEB summing

 CATEGORY:
	REDUCE

 CALLING SEQUENCE:
	FIX_OBESUMERRROR

 OPTIONAL INPUTS:
	Date:	If present processes the date specified.  Otherwise processes dates
		6 March 1997 -20 March 1997
	
 KEYWORD PARAMETERS:
	QL:	If present goes to the quick-look Directory, the default is QL
	LZ:	If present goes to the Level-0 Directory
	FIXIT:	If specified then writes the FITS file out, with LEBXSUM and LEBYSUM corrected.

 PROCEDURE:
	An error was discovered in OBE beginning 6 March 1997 through xx March.
	It started after sending a command to sum difference in EIT images.  
	The result was that the LEB summing parameter in the header was not 
	being set to the proper value.  It always read 1, even though the 
	summing was performed.

	This routine goes out to the date directory specified and reads in all of the FITS
	files one by one and then calls CHECK_OBESUMERROR to see if the error has
	occurred.  

 EXAMPLE:
	To see if the files on 970307 have the problem, use the following command:
		FIX_OBESUMERROR,'970307',/QL
	To correct the file
		FIX_OBESUMERROR,'970307',/QL,/FIXIT
	To correct all the files between 6 Mar and 20 Mar
		FIX_OBESUMERROR,/QL,/FIXIT

 MODIFICATION HISTORY:
	RA Howard, NRL, 23 March 97

	@(#)fix_obesumerror.pro	1.1 05/14/97 LASCO IDL LIBRARY


FIX_TIME_JUMP

[List of Routines] (See ./fix_time_jumps.pro)

 NAME:
	FIX_TIME_JUMP

 PURPOSE:
	This procedure reads a file from CDROM and puts the packets in
	order of the packets. If there is a gap, attempts to fill in 
	with QL packets using GET_MISSING_PCKTS.

 CATEGORY:
	LASCO PACKETS

 CALLING SEQUENCE:
	FIX_TIME_JUMPS,fname

 INPUTS:
	Fname:	Name of file with packets in it

 OUTPUTS:
       Outname:  Returns the temporary output file name

 SIDE EFFECTS:
	A file with same name as fname and at least as large is generated in $TMOUT

 PROCEDURE:
	The input files must reside in the current working directory.
	It then finds missing or out of order packets in science stream by 
	looking at the packet counter, which should increment by one.

 MODIFICATION HISTORY:
 	Written by:	R.A. Howard, NRL, 3 Aug 1996
	N. Rich 1/31/97	added tm_files variable
	RAH     2/04/97	Corrected high rate packet sizes
	N. Rich 3/29/97 added outdir variable
	N. Rich 1/2000	Implement GET_MISSING_PCKTS
	N. Rich 2/2000	Add ctrmin2 check
	N. Rich 4/2000	Fix case where badpckts are in middle; Use packet counter for gap
			if backwards clock-reset detected
		4/21/00  Print packet length of gaps and result (LZ 000207 ff.)
	n. rich 6/19/00  Change how it recognizes packet out of order, and previous packet
			 out of order
	n. rich 6/20/00  Start logging out-of-order packets
	jake 01/01/01	Up'd limit of numexp to 500000 to help 03240101.d01
	n.rich, 03.10.09 - Allow path in input filename

	@(#)fix_time_jumps.pro	1.8 10/10/03  LASCO IDL LIBRARY


FUZZY_BLOCK

[List of Routines] (See ./fuzzy/fuzzy_block.pro)

 PROJET:
	SOHO - LASCO

 NAME:
	FUZZY_BLOCK

 PURPOSE:
	Retrieves high-frequency information of a lost block using fuzzy logic

 PROCEDURE:
	Retrieves high-frequency information of a lost block using fuzzy logic
	reasoning on blocks specta
	
 CATEGORY:
	Missing Blocks, Interpolation

 CALLING SEQUENCE:
	block =	fuzzy_block (image, i, j)

 INPUTS:
	image		the image containing the block to correct
	i, j		the location (column, row) of this block

 KEYWORD INPUT:
	rebindex : rebin index (see fuzzy_image.pro)

 OUTPUTS:
	The corrected block (array of pixels) is returned

 SUB-ROUTINES:
	fuzzy_block.pro  contains the following sub-routines :

	_ num_to_fuzzy		convert a number to a fuzzy interval
	_ fuzzy_to_num		convert a fuzzy interval to a number
	_ inter_fuzzy		intersection of 2 fuzzy intervals
	_ FUZZY_BLOCK		perform a spectrum correction of a block
	  (=main routine)	using fuzzy logic reasoning

 REFERENCE:
	( see fuzzy_image.pro )

 MODIFICATION HISTORY:
	Written by J. MORE, October 1996
	Add of rebindex keyword on 28/01/2000 by A.Thernisien


FUZZY_IMAGE

[List of Routines] (See ./fuzzy/fuzzy_image.pro)


unction fuzzy_image,ima,HDR=hdr,VERBOSE=verbose, TOO_MANY=too_many, ALL=all

 PROJECT:
	SOHO - LASCO

 NAME:
	FUZZY_IMAGE

 PURPOSE:
	Corrects missing blocks on a image with a fuzzy logic method
	
 CATEGORY:
	Missing Blocks, Enhancement

 CALLING SEQUENCE:
	image =	fuzzy_image (ima,HDR=hdr)

 INPUTS:
	ima : the image containing blocks to correct

 OUTPUTS:
	The corrected image

 KEYWORDS:
	hdr : FITS header of the image. WARNING: If the image header is not passed, fuzzy_image concider that 
		the image is from C2 and 1024 * 1024: the procedure failed if it's not the case.
	verbose : print running informations
 	TOO_MANY: Flag for reduce_level_1.pro to mask missing blocks
	ALL:	Replace all missing blocks, regardless of number or mask

 SUBROUTINES:
	fuzzy_image.pro getl05hdrparam.pro sxpar.pro getok.pro get_tmask.pro get_miss_blocks.pro where2d.pro 
	hcie_zone.pro read_zone.pro grad_zone.pro tri_surf.pro reverse.pro write_zone.pro fuzzy_block.pro 
	read_block.pro dct.pro num_to_fuzzy.pro inter_fuzzy.pro fuzzy_to_num.pro write_block.pro

 REFERENCE:
		-> This method is based upon the following :
	Information Loss Recovery for Block-Based Image Coding Techniques
	- A Fuzzy Logic Approach
	Xiaobing Lee, Ya-Qin Zhang, Alberto Leon-Garcia
	IEEE TRANSACTIONS ON IMAGE PROCESSING, VOL.4, NO.3, MARCH 1995

 MODIFICATION HISTORY:
	V1.0 Written by J. MORE, October 1996
	Modif by A.T. 13/01/2000 and 18/01/2000: 
	- add of the HDR keyword the take account of the size and the detector. 
	- small modif to avoid crash when a missing block is near a non transmitted block
	1/23/01, nbr : Compute new blocks if number of good blocks in a zone greater than number of bad; 
		remove if statement for doing fuzzy_block; add TOO_MANY keyword
	12/4/01, nbr : Move function statement to top
	12/31/01, nbr :	Add ALL keyword
	 1/ 9/03, nbr : Add logfile; don't create window 2; change way n_in_zone is computed
	 3/20/03, nbr : Re-enable TOO_MANY and make threshold 16
	 4/ 9/03, nbr : add COMMON dbms, logging; add edge exclusion logic
	 4/11/03, nbr : set too_many equal to number missing; do not continue if gt 100 missing in a zone
       05.07.25, nbr - Update/fix too_many implementation for subfield cases

ersion = '@(#)fuzzy_image.pro	1.7, 07/25/05' ; LASCO IDL Library


FUZZY_TO_NUM

[List of Routines] (See ./fuzzy/fuzzy_to_num.pro)

 NAME:
	FUZZY_TO_NUM

 PURPOSE:
	Converts a fuzzy number to a number

 PROCEDURE:
	Converts a fuzzy number (or array of fuzzy numbers) to a number (or an
	array of numbers)

 CALLING SEQUENCE:
	a = fuzzy_to_num (afuzzy)

 INPUTS:
	afuzzy		a fuzzy number (scalar or array)

 OUTPUTS:
	The number (or array) best representing the fuzzy number (or array)


GETIDLPID

[List of Routines] (See ./getidlpid.pro)

 Project     : SOHO - LASCO/EIT

 Name        : GETIDLPID

 Purpose     : Returns IDL Process ID

 Use         : IDL>    result = GETIDLPID()

 Inputs      :

 Optional Inputs:

 Outputs     :

 Keywords    :

 Comments    :

 Side effects:

 Category    :

 Written     : Jake Wendt, NRL, April 10, 2002

 Version     :


   07/10/03 @(#)getidlpid.pro	1.4


GETL05HDRPARAM

[List of Routines] (See ./fuzzy/getl05hdrparam.pro)

 PROJET
	SOHO-LASCO

 NAME:
	getl05hdrparam

 PURPOSE:
	Extracts from fits header parameters of the image

 CATEGORY
	Fits Management

 CALLING SEQUENCE:
	getl05hdrparam,hdr,hdrfieldstruct

 INPUTS:
	hdr : header of a C2 or C3 image
     
 KEYWORD INPUT:
	offsetbias : set to compute the electronical offset bias

 OPTIONAL INPUTS PARAMETERS:
     none

 OUTPUTS:
	structure containing image parameters
		filename : FILENAME
		bitpix : BITPIX
		detector : DETECTOR
		sx : NAXIS1
		sy : NAXIS2
		fystart : R1ROW-1
		fxstart : R1COL-20
		fyend : P2ROW-1
		fxend : P2COL-20
		nrebinx : (fxend-fxstart+1)/sx
		nrebiny : (fyend-fystart+1)/sy
		bias : bias give by offset_bias
		lebxsum : LEBXSUM
		lebysum : LEBYSUM
		sumcolx : SUMCOL (1,2,4: 1 instead of 0 in the header)
		sumrowy : SUMROW (1,2,4: 1 instead of 0 in the header)
		rebindex : = nrebinx if nrebinx==nrebiny else =-1

 OPTIONAL OUTPUT PARAMETERS:
     none


 CALLED ROUTINES:
	t_param.pre_offset_bias

 HISTORY:
		V1.0 coded by A.Thernisien on 17/01/2000 based upon ima05dim.pro from A.LL


GET_C3_BKGD.PRO

[List of Routines] (See ./las_c3/get_c3_bkgd.pro)

 PROJET:
     SOHO-LASCO

 NAME:
     get_c3_bkgd.pro

 PURPOSE:
     get fit coefficients of the strayligh edge on C3

 CATEGORY
     Pipeline, level1, straylight

 CALLING SEQUENCE:
     get_c3_bkgd, imain, xc, yc, profle, jpix, coef, ierr

 INPUTS:
     imain         file with a full image name (includes the path) per line
     xc            x coord. of occultor center
     yc            y coord. of occultor center

 OUTPUTS:
     profle        values of pylone profile
     jpix          abscisses of pylone profile
     coef          regression coefficients
     ierr          -1 for not square images of 1024x1024 or 512x512 or 256x256 pixels  

 RESTRICTIONS:
     Procedure appliable only to square images of 1024x1024 or 512x512 or 256x256 pixels

 KEYWORD OUPUTS:
     IPIXN
     JPIXN
     IPOS

 PROCEDURE:

 HISTORY:


GET_CAL_DARK

[List of Routines] (See ./get_cal_dark.pro)

 NAME:
	GET_CAL_DARK

 PURPOSE:
	This function obtains the dark field calibration structure
	applicable to the current date and telescope configuration

 CATEGORY:
	REDUCTION

 CALLING SEQUENCE:
	GET_CAL_DARK, Tel_num, Date, Obs_mode, Dark

 INPUTS:
	Tel_num 	The telescope number [0=C1,.., 3=EIT]
	Date 		The date of the image (format = DATE-OBS)
	Obs_mode 	The telescope configuration (DBMS parameter)

 OUTPUTS:
	Dark		The dark image calibration data structure
       Function result Gives the status of the search: 
	   		0 if the calibration file could not be found.
			1 if successful 

 COMMON BLOCKS
       DBMS, ludb,lulog

 SIDE EFFECTS
       An entry is written into a log file if the unit number exists

 MODIFICATION HISTORY:
     Written	RA Howard, NRL, 4 October 1995

       @(#)get_cal_dark.pro	1.1 04 Apr 1996 LASCO IDL LIBRARY


GET_CAL_PHOTOM

[List of Routines] (See ./get_cal_photom.pro)

 NAME:
	GET_CAL_PHOTOM

 PURPOSE:
	This function obtains the photometric calibration data structure
	applicable to the current date and telescope configuration

 CATEGORY:
	REDUCTION

 CALLING SEQUENCE:
	GET_CAL_PHOTOM, Tel_num, Date, Obs_mode, Photo

 INPUTS:
	Tel_num 	The telescope number [0=C1,.., 3=EIT]
	Date		The date of the image (format = DATE-OBS)
	Obs_mode 	The telescope configuration

 OUTPUTS:
	Photo		The photometric calibration data structure
	Function Result	Gives the status of the search
			0 if calibration file not found
			1 if file found

 COMMON BLOCKS:
	DBMS, ludb, lulog

 SIDE EFFECTS:
	An entry in the processing log is produced if lulog is defined

 PROCEDURE:
	GET_CAL_STRUCT is called to find the appropriate calibration file,
       which is an IDL save set. Then the data is restored and an entry
	is made in the processing log.

 MODIFICATION HISTORY:
	Written		RA Howard, NRL, 4 October 1995

       @(#)get_cal_photom.pro	1.1 04 Apr 1996 LASCO IDL LIBRARY


GET_CAL_STRAY

[List of Routines] (See ./get_cal_stray.pro)

 NAME:
	GET_CAL_STRAY

 PURPOSE:
	This function obtains the stray light data structure applicable to 
	the current date and telescope configuration

 CATEGORY:
	REDUCTION

 CALLING SEQUENCE:
	GET_CAL_STRAY, Tel_num, Date, Obs_mode

 INPUTS:
	Tel_num 	Telescope number [0=C1,.., 3=EIT]
	Date 		Date of the image (format = DATE-OBS)
	Dbs_mode 	Telescope configuration

 OUTPUTS:
	Stray 		Stray Light calibration structure
	Function Result The status of the query is returned as the 
			function result: 0 if cal file was not found
			and 1 if it was found.

 COMMON BLOCKS:
	DBMS, ludb, lulog

 SIDE EFFECTS:
	An entry is written to the log file if lulog in the common block is
	defined.

 PROCEDURE:
	GET_CAL_STRUCTURE is called to obtain the name of the appropriate
	calibration file.  Then the file (an IDL save set) is restored.

 MODIFICATION HISTORY:
     Written	RA Howard, NRL, 4 October 1995

       @(#)get_cal_stray.pro	1.1 04 Apr 1996 LASCO IDL LIBRARY


GET_CAL_STRUCT

[List of Routines] (See ./get_cal_struct.pro)

 NAME:
	GET_CAL_STRUCT

 PURPOSE:
	This function is a general purpose function procedure to first 
	read the date cal file, find the applicable calibration file, and 
	then return the calibration structure

 CATEGORY:
	REDUCTION

 CALLING SEQUENCE:
	GET_CAL_STRUCT, Type, Tel_num, Date, Obs_mode, Filename

 INPUTS:
	Type       	String containing type of calibration file
	Tel_num    	Telescope number (0..3)
	Date       	Date and Time of image to be calibrated (format=UTC/ECS)
	Obs_mode   	Observing Mode number

 OUTPUTS:
	Filename	Filename of calibration file
	Function Result	the status of the query
               	0 = Valid
               	1 = Invalid

 COMMON BLOCKS:
	DBMS, ludb, lulog

 PROCEDURE:
	The file whose file name is built from the calibration type
	is opened and read.  The file names are 
		photo_date_config.txt
		stray_date_config.txt
		dark_date_config.txt
		vig_date_config.txt
	These files have records in the following format:

	telescope_number, date_start,date_end, configuration, filename
	where:
		Telescope_number is the number from 0 to 3 for C1 to EIT
		Date_start is the starting valid date and time 
		End_start is the ending valid date and time 
		Filename is the name of the calibration file

 MODIFICATION HISTORY:
     Written		RA Howard, NRL, 4 October 1995

       @(#)get_cal_struct.pro	1.1 04 Apr 1996 LASCO IDL LIBRARY


GET_CAL_VIGNET

[List of Routines] (See ./get_cal_vignet.pro)

 NAME: 			GET_CAL_VIGNET

 PURPOSE:			Obtains the appropriate vignetting calibration
				file for the date and observing mode

 CATEGORY: 			REDUCTION

 CALLING SEQUENCE: 		Result = GET_CAL_VIGNET
					    (Tel_num,Date,Obs_mode,Vig)

 INPUTS:			Tel_num = Telescope Number (0..3)
				Date = Date of observation (format = UTC/ECS)
				Obs_mode = Telescope configuration

 OUTPUTS:			Vig = Vignetting calibration structure
				Result = status of operation 
					1=success
					0=failure

 COMMON BLOCKS:		DBMS

 SIDE EFFECTS:			A log entries are written to unit LULOG

 PROCEDURE:			The routine get_cal_struct is called to find
				the file name for the appropriate date and 
				configuration, and then the cal structure is 
				restored.

 MODIFICATION HISTORY: 	WRITTEN	     RA Howard, NRL, 4 October 1995
				Version 1    RAH  Initial Release

       @(#)get_cal_vignet.pro	1.1 04 Apr 1996 LASCO IDL LIBRARY


GET_CROTA

[List of Routines] (See ./get_crota.pro)

 Project     : SOHO - LASCO/EIT

 Name        : GET_CROTA

 Purpose     : Returns Nominal Roll Attitude of SOHO ( degrees )

 Use         : IDL>    result = GET_CROTA( DATE )

 Inputs      : DATE in format 2003/07/21 23:30:05.469

 Optional Inputs:

 Outputs     : Roll Attitude

 Keywords    :

 Comments    :
			# Nominal roll attitude of SOHO (degrees)
			#
			1995-12-02 03:08:00   0.00
			2003-07-08 13:00:00 180.00
	
		IDL[hercules]>print, GET_CROTA('2003-07-08 12:59:59')
		      0.00000
		IDL[hercules]>print, GET_CROTA('2003-07-08 13:00:00')
		      180.000

 Side effects:

 Category    :

 Written     : Jake Wendt, NRL, July 10, 2003

 Version     :	030722	jake	changed location of nominal_roll_attitude.dat
				030804, nbr - Add ANCIL_DATA, check only uncommented lines of file 


   08/04/03 @(#)get_crota.pro	1.7


GET_MISSING_PCKTS

[List of Routines] (See ./get_missing_pckts.pro)

 NAME:
	GET_MISSING_PCKTS

 PURPOSE:
	Searches index of REL/QKL files between times tai0 and tai1 (exclusive).
	If there are any packets in this interval, return them in
	'result'. Otherwise return 0.

 CATEGORY:
	LASCO PACKETS

 INPUTS:
	tai0	LONG	Tai time (seconds) of last packet before gap
	tai1	LONG	Tai time of first packet after gap
 
 Keywords:
	USE_CTR		If set, use packet counter instead of time to fill gap
			(necessary when LOBT clock is reset backwards). Set equal to
			[lastctr,ctr] (counter before and after gap)

 OUTPUTS:
       Result:  BYTARR(packet length, number of packets)

 SIDE EFFECTS:


 PROCEDURE:


 MODIFICATION HISTORY:
 	Written by:	N.B. Rich, Jan. 2000
	NBRich	Apr 2000 - Account for case where files(ind0-1) includes files(ind0);
			   Add USE_CTR keyword
	jake			-	changed /net/gorgon/gg3/ql/ to GETENV('QL_IMG')
	03.10.08, nbr - Changed input index.txt name/location

	10/08/03 @(#)get_missing_pckts.pro	1.5 LASCO IDL LIBRARY


GET_MISS_BLOCKS

[List of Routines] (See ./fuzzy/get_miss_blocks.pro)

 PROJET:
	SOHO - LASCO

 NAME:
	GET_MISS_BLOCKS

 PURPOSE:
	Finds all the missing blocks on an image

 PROCEDURE:
	Finds all the missing blocks on an image, and designs the corresponding
	"missing zones"; returns a map of the missing blocks where each
	missing block is then given the number of the missing zone it belongs
	A missing zone is defined as the smallest rectangle that surrounds a
	cluster of missing blocks (likely to be neighbor missing blocks) but
	has no missing blocks on its border (its outermost rows and columns)

	Call this routine before using a chain of correction, otherwise the
	location of all missing blocks would be lost after the 1st correction

 CATEGORY:
	Detection, Missing Blocks

 CALLING SEQUENCE:
	get_miss_blocks, image, map_miss_blocks
                        [ , list_miss_blocks, n_miss_blocks ]

 INPUTS:
	image			the image to make the map of

 OUTPUTS:
	map_miss_blocks		the map of the missing blocks, a 32x32 array
				Assume there are nz missing zones, then each
				element (i,j) on the map represents the state
				of the block at column i and row j :
				_ (-1) means it's a correct block
				_ A integer z (from 0 to nz-1) means this is a
				  missing block belonging to the "z"th zone
 OPTIONAL OUTPUT:
	list_miss_blocks	the total list of missing blocks, a 2 columns
				array, where each row (i,j) represents the
				location of a missing block
	n_miss_blocks		the total number of missing blocks

 KEYWORD INPUT:
	detector : C2 or C3 to get the non transmitted block mask (default:C2)
	rebindex : 0: 1024 * 1024, 1: 512 * 512, 2:256 * 256
	ALL:	Do not get block mask

 EXAMPLE:
	Given a image "image1" with missing blocks, get its map:
		get_miss_blocks, image1, map_b

	Print the list and the number of missing blocks :
		print, where2d(map_b ge 0, n_b)  &  print, n_b

	Get the number of missing zones, then for each missing zone print the
	blocks it contains :
		n_z = max(map_b)+1
		for z=0, n_z - 1 $
			print, where2d(map_b eq z)
	
 MODIFICATION HISTORY:
	Written by J.MORE, September 1996
	Modif 13/01/2000 A.T. add of detector and rebindex keyword
	1/24/01, nbr - extend zone to two blocks in each direction instead of one
	12/31/01, nbr - Add ALL keyword
	 4/10/03, nbr - Modify map_miss_blocks criteria


GET_NEW_FILE_NUMBER

[List of Routines] (See ./get_new_file_number.pro)

 NAME:				GET_NEW_FILE_NUMBER

 PURPOSE:			Finds the last file number for the given
				telescope and source and increments it.

 CATEGORY:			REDUCTION

 CALLING SEQUENCE:		Result = GET_NEW_FILE_NUMBER(Tel, Source)

 INPUTS:			Tel  =  Telescope number (0..3)
				Source = 0 for GSFC R/T
					 1 for NRL R/T
					 2 for NRL Playback
					 7 for test

 OUTPUTS:			Result = Number to be used for file name 

 COMMON BLOCKS:		DBMS

 PROCEDURE:			An entry is recorded in the processing log
				when the file number is found.

 MODIFICATION HISTORY:		Written	RA Howard, NRL
				Version 1	Initial Release 31 Oct 1995
				Version 2  17 Jan 96 Added testing source
				Version 3  11 Feb 97 SEP Changed num to type LONG
				29 Aug 2000, nbr - Use $LAST_IMG instead of $IMAGES
				11 Oct 2000, nbr - Use $IMAGES if source=0

       @(#)get_new_file_number.pro	1.3 01/12/01 ; NRL LASCO IDL LIBRARY


GET_TEL_CONFIG

[List of Routines] (See ./get_tel_config.pro)

 NAME:				GET_TEL_CONFIG

 PURPOSE:			Computes the telescope configuration number,
				given the telescope, the telescope mechanism 
				configuration, and the camera configuration in 
				the header

 CATEGORY:			REDUCTION

 CALLING SEQUENCE:		Result = GET_TEL_CONFIG(Tel_num,Fits_hdr)

 INPUTS:			Tel_num = Telescope number (0..3)
				Fits_hdr = String containing the FITS header

 OUTPUTS:			Result = Configuration number

 MODIFICATION HISTORY: 	WRITTEN RA Howard NRL 
				Version 1   RAH 20 Oct 1995  Initial Release
     				Version 2   RAH 6 Nov 1995  compute number 
						rather than use DBMS

       @(#)get_tel_config.pro	1.1 04 Apr 1996 LASCO IDL LIBRARY


GET_TMASK

[List of Routines] (See ./fuzzy/get_tmask.pro)

 PROJET
     SOHO - LASCO
 NAME:
     get_tmask
 PURPOSE:
     Classify blocks of image level 0.5
 CATEGORY:
	Masking, Missing Blocks
 CALLING SEQUENCE
     get_tmask,camera,rebin_index,imsk
 INPUTS
     camera       string 'C1','C2','C3'     
     rebin_index  0=1024x1024, 1=512x512, 2,256x256
 KEYWORD INPUTS:
     none
 OUTPUTS:

     imsk       intarray of 32x32, multivalued image mask of 
                -2 non useful blocks (NUB) on the corner
                -1 non useful blocks (NUB) on center
                1    useful blocks 
                2    fringe blocs
                3    NS center fringe blocs
                4    EW center fringe blocs
                note: 0 is reserved for non transmitted useful blocks
 PROCEDURE:


 HISTORY:
    written by A.LL. May 1996


GRAD

[List of Routines] (See ./fuzzy/hcie_zone.pro)

 NAME:
       GRAD

 PURPOSE:
       Designs a "gradient map", i.e. a image made with parallel lines, all of
       them perpendicular to a given gradient direction

 CALLING SEQUENCE:
       g = grad (xsize, ysize, theta)

 INPUTS:
       xsize, ysize    the size of the map image
       theta           the angle of the gradient vector (versus the (Ox) axis)
                       expressed in radians; the parallel lines are thus
                       along the direction theta+pi/2

 OUTPUTS:
       the (xsize) x (ysize) array where the value of each point is equal to
       the distance beetween the line perpendicular to the gradient that pass
       through this point and the origin.
       The origin (just as for the dist function) is located at 1 of the 4
       corner of the image,  depending on the value of theta :
       _ for theta in [0, pi/2],      the origin = (0, 0)
       - for theta in [pi/2, pi],     the origin = (xsize-1, 0)
       _ for theta in [pi, 3.pi/2],   the origin = (xsize-1, ysize-1)
       - for theta in [3.pi/2, 2.pi], the origin = (0, ysize-1)


GRAD_ZONE

[List of Routines] (See ./fuzzy/grad_zone.pro)

 NAME:
	GRAD_ZONE

 PURPOSE:
	Returns the main gradient orientation of a zone containing MB

 CATEGORY:
	Missing Blocks

 CALLING SEQUENCE:
	angle = grad_zone (image, list_miss_blocks)

 INPUTS:
	image			the image containing missing blocks
	list_miss_blocks	the missing blocks defining the zone

 KEYWORD INPUT:
	rebindex : rebin index (see fuzzy_image.pro)

 OUTPUTS:
	The angle of the gradient vector

 MODIFICATION HISTORY:
	Written by J. More, November 1996
	Add of rebindex keyword on 28/01/2000 by A.Thernisien


HCIE_ZONE[1]

[List of Routines] (See ./fuzzy/hcie_zone.pro)

       hcie_zone.pro  contains the following sub-routines :

       _ grad                  designs a image made with parallel lines, all
				of them perpendicular to a given direction
       _ multi_interp		perform a multiple 1D interpolation of an image
				along a set of parallel lines
       _ multi_smooth		perform a multiple 1D smoothing of an image
				along a set of parallel lines
       _ HCIE_ZONE             performs a H.C.I.E. (Hierarchical Compass
         (=main routine)       Interpolation/Extrapolation), i.e. a low-pass
                               recovery, on a set of missing block (defining
				a missing zone)


HCIE_ZONE[2]

[List of Routines] (See ./fuzzy/hcie_zone.pro)

 PROJET:
       SOHO - LASCO

 NAME:
	HCIE_ZONE

 PURPOSE:
       Performs the Hierarchical Compass Interpolation / Extrapolation
       (H.C.I.E.), which is a low-frequency recovery of a lost block

 CATEGORY:
	Missing Blocks

 CALLING SEQUENCE:
       zone = hcie_zone (image, list_miss_blocks)

 INPUTS:
       image           	the image containing the block to correct
       list_miss_blocks	the locations of the missing blocks defining
				the zone
 KEYWORD INPUT:
	rebindex : rebin index (see fuzzy_image.pro)

 OUTPUTS:
       The corrected zone (array of pixels) is returned

 REFERENCE:
       ( see fuzzy_image.pro )

 MODIFICATION HISTORY:
	from the wonderful Dr. M.BOUT (c) 1996
       Written by J. MORE, November 1996
	Add of rebindex keyword on 28/01/2000 by A.Thernisien
	Modif line 219 on 11/02/2000 by A.T. to avoid crash when there are not enough sample for interpolation


INTER_FUZZY

[List of Routines] (See ./fuzzy/inter_fuzzy.pro)

 NAME:
	INTER_FUZZY

 PURPOSE:
	Compute the intersection of 2 fuzzy numbers

 PROCEDURE:
	Compute the intersection of 2 fuzzy numbers (this for each element in
	the case of fuzzy number arrays)

 CALLING SEQUENCE:
	cfuzzy = inter_fuzzy (afuzzy, bfuzzy)

 INPUTS:
	afuzzy, bfuzzy		2 fuzzy numbers (or fuzzy number arrays)

 OUTPUTS:
	a fuzzy number (structure {low, high}) or array of fuzzy numbers


INTTOB32

[List of Routines] (See ./mb2str/inttob32.pro)

 PROJET
     SOHO-LASCO

 NAME:
  INTTOB32

 PURPOSE:
  Convert a integer to a base 32 number

 CATEGORY:
  Mathematics

 CALLING SEQUENCE:
   
 DESCRIPTION:

 INPUTS:

 INPUT KEYWORD:

 OUTPUTS:

 PROCEDURE:
  
 CALLED ROUTINES:

 HISTORY:
	V1 A.Thernisien 10/07/2001
 CVSLOG:
  $Log: inttob32.pro,v $
  Revision 1.2  2002/07/11 07:24:12  arnaud
  Insertion of the Log in each header



MAKE_BROWSE

[List of Routines] (See ./make_browse.pro)

 NAME:
		MAKE_BROWSE

 PURPOSE:
		Generates a "browse" image from the input image

 CATEGORY:
		REDUCTION

 CALLING SEQUENCE:
		Result = MAKE_BROWSE (Image, File_name)

 INPUTS:
		Image = Input 2D image
		File_name = String containing the File name 

 KEYWORD PARAMETERS:
		Maxpix = Maximum number of columns or rows of browse image. 
                        If maxpix of browse image is not defined then set to 
                        256
		Noblob = Controls the output
		Nokeep = Delete the JPEG file
		Qual   = starting quality indicator (<=100)

 OUTPUTS:
		Result = The JPEG compressed browse image is returned as the 
			 function result if noblob is not set.  If set the 
			 output is the browse image without compression

 PROCEDURE:

      The browse image is defined to be a byte array not larger than the 
      optional input parameter or a default size if it is not defined.  The 
      browse image is compressed using the JPEG algorithm.  The objective is 
      to create a representation of the full image which is less than 3 kbytes,
      in order to be able to quickly transfer the information electronically.
      The browse image can then be used to determine if the full image should 
      be transferred, which might take much longer to transfer.  The browse 
      image is not intended to be used for analysis purposes.

      browse = JPEG ( bytscl (congrid(image,maxpix,maxpix)))

 MODIFICATION HISTORY:
	Written  RA Howard, NRL, 4 Oct 1995
       Version 1
       Version 2  RAH  2/12/96   Changed order from 1 to 0
       Version 3  RAH  3/09/96   Write image to specific directory and 
                                 optionally save.  Scale image using log
       Version 4  RAH  3/29/96   Changed max size to 2000 bytes, qf=90
       Version 5  RAH  4/20/96   Removed "w" as second character in name
       Version 6  RAH  5/15/96   Corrected error if zeros everywhere
       Version 7  RAH  5/25/96   Use histogram equalization to scale image
       Version 8  RAH  10/21/96  Subtract background model
       Version 9  RAH  02/20/97  Correct case of constant image
	VERSION 10 NBR	02/01/02  Add /SH to SPAWN

       @(#)make_browse.pro	1.8 02/01/02 LASCO IDL LIBRARY


MAKE_FITS_HDR

[List of Routines] (See ./make_fits_hdr.pro)

 NAME:				MAKE_FITS_HDR

 PURPOSE:			Generate a FITS header for Level 0.5 images

 CATEGORY:			REDUCTION

 CALLING SEQUENCE:		Result = MAKE_FITS_HDR (h,img)

 INPUTS:			H   = Header structure
				Img = Image

 OUTPUTS:			Result = FITS header

 PROCEDURE:			Makes calls to FXADDPAR

 MODIFICATION HISTORY:		Written RA Howard, NRL, 31 Oct 1995
   Version 2  rah 16 Nov 1995   Converted filter/polarizer/lp_num/readport
   Version 3  rah 11 Dec 1995   Corrected tag name of polarizer & eit/detector
   Version 4  rah 18 Jan 1996   Corrected exposure time to be entire exp & 
                                added subsection times
   Version 5  rah 15 Feb 1996   Corrected DATE-OBS/TIME-OBS
   Version 6  rah 22 Feb 1996   Corrected FP WL Keywords to be 8 characters
   Version 7  rah 18 Mar 1996   Added KW for LEB summing, and corrected exptime
   Version 8  rah 19 Mar 1996   Corrected exposure time for dark and continuous images
   Version 9  rah 27 Mar 1996   Corrected lp_num structure tag
   Version 10 rah 03 Apr 1996   Modified exposure mid point names
   Version 11 rah 05 Apr 1996   Compute exposure time in real
   Version 12 sep 17 Jul 1996   Modified to work with new LEB header (obev145+)
                                units on exp[1,2,3], version, order
   Version 13 rah 22 Jul 1996   Increased WAVELENG to double precision
   Version 14 rah 01 Aug 1996   Modified exptime calc for new OBE version
                                Increased FP_WL* to double precision
   Version 15 sep 18 Jun 1997   Changed call for new OFFSET_BIAS()
   Version 16 rah 18 Jul 1997   BITPIX set to reflect the image data type

 @(#)make_fits_hdr.pro	1.10 07/24/97 :NRL Solar Physics


MAKE_INDEX

[List of Routines] (See ./make_index.pro)

 Project     : SOHO - LASCO/EIT

 Name        :	MAKE_INDEX

 Purpose     :

 Use         : IDL>

 Inputs      :

 Optional Inputs:

 Outputs     :

 Keywords    :

 Comments    :

 Side effects:

 Category    :

 Written     :

 Version     :

 Modification:	020606 Jake Changed End of Repeat loop to check numpckts as well
	03.10.08, nbr - change name of output file

 @(#)make_index.pro	1.5 10/08/03 :LASCO IDL LIBRARY


MB2STRMAP

[List of Routines] (See ./mb2str/mb2strmap.pro)

 PROJET:
	SOHO - LASCO

 NAME:
	MB2STRMAP

 PURPOSE:
  Convert a missing block image map to a 'string map'

 CATEGORY:
  missing blocks

 CALLING SEQUENCE:


 INPUTS:

 OUTPUTS:


 OPTIONAL OUTPUTS:

 KEYWORD INPUT:


 MODIFICATION HISTORY:
	V1.0 Writen by A.Thernisien on 18/09/2001
 CVSLOG:
  $Log: mb2strmap.pro,v $
  Revision 1.2  2002/07/11 07:24:17  arnaud
  Insertion of the Log in each header



MISS_BLOCKS

[List of Routines] (See ./miss_blocks.pro)

 NAME:
	MISS_BLOCKS

 PURPOSE:
	This function returns a list of the missing telemetry block numbers.

 CATEGORY:
	REDUCE

 CALLING SEQUENCE:
	Result = MISS_BLOCKS (Img, Hdr)

 INPUTS:
	Img:	The image to be processed
	Hdr:	The fits header of the image

 OUTPUTS:
	The function result is a long word array of the absolute block numbers
	that are missing.  If no blocks are missing, the result is -1.

 PROCEDURE:
	The input image is rebinned to a 32 x 32 array and then teh IDL where 
	function is used to identify the locations where the super pixels are
	zero.

 MODIFICATION HISTORY:
 	Written by:	RA Howard, 4 Oct 1995

	@(#)miss_blocks.pro	1.1 10/05/96 LASCO IDL LIBRARY


MOVE_REDUCE_LOG

[List of Routines] (See ./move_reduce_log.pro)

 NAME:
	MOVE_REDUCE_LOG

 PURPOSE:
	This procedure moves the log and db files produced by the pipeline 
	processing from the directory pointed to by $REDUCE_LOG into 
	subdirectories by process date.

 CATEGORY:
	REDUCE

 CALLING SEQUENCE:

	MOVE_REDUCE_LOG

 OPTIONAL INPUTS:
	Dte:	String giving the date to be processed in the format YYMMDD.
		The default is to process all files.

 OUTPUTS:
	None

 SIDE EFFECTS:
	Moves files into a subdirectory

 MODIFICATION HISTORY:
 	Written by:	R.A. Howard, NRL, 25 Apr 1996
	2002.02.01, NBR - Add /SH to SPAWN

	@(#)move_reduce_log.pro	1.2 02/01/02 LASCO IDL LIBRARY


MULTI_INTERP

[List of Routines] (See ./fuzzy/hcie_zone.pro)

 NAME:
       MULTI_INTERP

 PURPOSE:
       Performs a multiple 1D interpolation on a 2D image, along a set of
	lines given by a map (for ex. parallel lines)

 CALLING SEQUENCE:
       interp_array = multi_interp (array, map, theta)

 INPUTS:
	array		an array to interpolate; interpolation is performed
			on missing values within the array (i.e. null values)
			thanks to the correct values (non-null values)
	map		an array of the same dimensions, showing the location
			of lines where to performs the multiple interpolations
			The value of each pixel in that map is the number of
			the line it belongs to (0, 1, ..., N-1) for N lines
	theta		the angle perpendicular to the parallel lines

 OUTPUTS:
	The interpolated array


MULTI_SMOOTH

[List of Routines] (See ./fuzzy/hcie_zone.pro)

 NAME:
       MULTI_SMOOTH

 PURPOSE:
       Performs a multiple 1D smoothing on a 2D image, along a set of
	lines given by a map (for ex. parallel lines)
	Multi-smooth works exactely in the same way than multi-interp

 CALLING SEQUENCE:
       smooth_array = multi_smooth (array, map, theta)

 INPUTS:
	array		an array to smooth
	map		an array of the same dimensions, showing the location
			of lines where to performs the multiple smoothing
	theta		the angle perpendicular to the parallel lines

 OUTPUTS:
	The smoothed array


NUM_TO_FUZZY

[List of Routines] (See ./fuzzy/num_to_fuzzy.pro)

 NAME:
	NUM_TO_FUZZY

 PURPOSE:
	Converts a number to a fuzzy number

 PROPCEDURE:
	Converts a number (or array of numbers) to a fuzzy number (resp. array
	of fuzzy numbers with the same dimensions)

	A "fuzzy number" is a confidence interval around a given number.
	Given 1 number a0 (highest confidence case) and a [min,max] interval
	(lowest confidence case), the fuzzy number is an compromise beetween
	[amin,amax] and [a0, a0] according to a confidence level (0 to 1) for
	the number a0.
;	
 CALLING SEQUENCE:
	afuzzy = num_to_fuzzy (a0, amin, amax, conf)

 INPUTS:
	a0		a non-complex number or array of numbers
	amin		the minimum value for a confidence level 0
	amax		the maximum value for a confidence level 0
	conf		a confidence level, ranging from 0 (no confidence in
			the number a0) to 1 (total confidence in the number a0)

 OUTPUTS:
	A fuzzy number (structure with the form {low,high})


PHOTOCAL

[List of Routines] (See ./photocal.pro)

 NAME:				PHOTOCAL

 PURPOSE:			Performs the Level 1 photometric calibration of
				an image from digital counts to mean solar 
				brightness units

 CATEGORY:			REDUCTION

 CALLING SEQUENCE:		Result = PHOTOCAL (X,Hx,Cal,Stray,Vig,Dark,Hnew)

 INPUTS:			X = Input uncalibrated image
				Hx = Header structure for X
				Cal = Photometric Calibration Structure
				Stray = Stray Light Calibration Structure
				Vig = Vignetting Calibration Structure
				Dark = Dark Image Calibration Structure

 OUTPUTS:			Result = Calibrated image
				Hnew = New FITS header

 COMMON BLOCKS:

 SIDE EFFECTS:

 RESTRICTIONS:

 PROCEDURE:

     The LASCO calibration images will be derived from flat field images
     through each filter / polarizer at several known brightness levels and
     for several exposure times.  The flat field images also contain 
     information about the vignetting function, but this information will be
     backed out of the flat fields to create the calibration images used
     here.  A dark field image will be used to subtract off any dark
     counts for that exposure time and to correct for any electronic
     bias that is introduced.

     The CCD response is linear.  However, there may be non-linearity due
     to the shutter opening and closing times.  This gives the following 
     formula to convert a raw image, in counts, to a calibrated image, in 
     photometric units.

     B  =  ( cal.B1 + cal.slope * ( xd - DN1 ) * ( cal.e1 / exptime ) )
           *  vig.img   -  stray.img

     DN1 = cal.img1 + ( ( cal.img3 - cal.img1 ) ) / ( cal.e3 - cal.e1 ) ) 
                       * ( exptime - cal.e1 )

     xd  = x - dark1

     dark1 = dark.img1 + ( (dark.img2 - dark.img1) ) / (dark.e2 - dark.e1) )
                          * ( exptime - dark.e1 )

     where,
           cal.e1    = exposure time for reference image #1
           cal.B1    = brightness level of reference image #1
           cal.slope = slope to convert DN to MSB for exposure e1
           x         = observed image in counts (DN)
           hx        = FITS header associated with image, x
           exptime   = current exposure time (in FITS header)
           DN1       = reference image at current exposure time
           dark1     = dark field image at current exposure time
           xd        = observed image in counts with dark field subtracted
           stray.img = stray light image
           vig.img   = vignetting correction image
                       The vignetting correction is the reciprocal of the 
                       function in the range of [0,1] except that close to 
                       the occulting disk where the function is close to 0, 
                       the correction might be set to 0, rather than permit 
                       the very large correction.
           hnew      = FITS header associated with calibrated image

     cal is an idl structure containing the following elements

           version   = version identification (string)
           date      = date generated (string)
           start     = start date and time when valid (UTC string)
           end       = end date and time when valid (UTC string)
           teles     = telescope (integer)
           tel_conf  = telescope configuration (integer)
           cam_conf  = camera configuration (integer)
           e1        = exposure time at reference image #1 (float)
           e2        = exposure time at reference image #2 (float)
                       (must be equal to e1)
           e3        = exposure time at reference image #3 (float)
           B1        = brightness level of reference image #1 (float)
           B2        = brightness level of reference image #2 (float)
           B3        = brightness level of reference image #3 (float)
                       (must be equal to B1)
           img1      = reference image #1 (integer image) dark subtracted
           img2      = reference image #2 (integer image) dark subtracted
           img3      = reference image #3 (integer image) dark subtracted
           slope     = slope of linear conversion (MSB/DN) (float image)

     dark is an idl structure containing the following elements

           version   = version identification (string)
           date      = date generated (string)
           start     = start date and time when valid (UTC string)
           end       = end date and time when valid (UTC string)
           teles     = telescope (integer)
           tel_conf  = telescope configuration (integer)
           cam_conf  = camera configuration (integer)
           e1        = exposure time at reference image #1 (float)
           e2        = exposure time at reference image #2 (float)
           img1      = reference image #1 (integer image) dark subtracted
           img2      = reference image #2 (integer image) dark subtracted

     stray is an idl structure containing the following elements

           version   = version identification (string)
           date      = date generated (string)
           start     = start date and time when valid (UTC string)
           end       = end date and time when valid (UTC string)
           teles     = telescope (integer)
           tel_conf  = telescope configuration (integer)
           cam_conf  = camera configuration (integer)
           img       = stray light image (float image)

     vig is an idl structure containing the following elements

           version   = version identification (string)
           date      = date generated (string)
           start     = start date and time when valid (UTC string)
           end       = end date and time when valid (UTC string)
           teles     = telescope (integer)
           tel_conf  = telescope configuration (integer)
           cam_conf  = camera configuration (integer)
           img       = vignetting correction image (float image)


 MODIFICATION HISTORY:
     Written R.A. Howard, Naval Research Lab, 23 Apr 1993
         Version 1
                 2   RAH, 12 Nov 1994 additional comments
                 3   RAH, 3 Oct 1995 added sub image capability
                                     header is in fits format
                                     adding dark image correction
                 4   RAH, 15 Nov 1995 added additional HISTORY to header

       @(#)photocal.pro	1.1 04 Apr 1996 LASCO IDL LIBRARY


READ_BLOCK

[List of Routines] (See ./fuzzy/read_block.pro)

 PROJEcT:
       SOHO - LASCO

 NAME:
       READ_BLOCK

 PURPOSE:
       returns the block (array of pixel) at column i and row j

 CATEGORY:
       Missing Blocks

 CALLING SEQUENCE:
       block = read_block (image, i, j)

 INPUTS:
       image           the image where to read the block onto
       i, j            the column i and the row j of the block
                       (i and j ranges from 0 to 31)

 KEYWORD PARAMETERS:
       SIDE            the side of the square blocks (default is 32 pixels)

 OUTPUTS:
       The function returns the corresponding block, a 32 x 32 integer array

 MODIFICATION HISTORY:
       written by J.More, September 1996


READ_ZONE

[List of Routines] (See ./fuzzy/read_zone.pro)

 PROJET:
	SOHO - LASCO

 NAME:
	READ_ZONE

 PURPOSE:
	Gets the missing zone surrounding a given list of missing blocks

 PROCEDURE:
	Gets the missing zone (array of pixel) surrounding a given list of
	missing blocks

	A missing zone is defined as the smallest rectangle of blocks that
	surrounds a cluster of missing blocks (likely to be neighbor missing
	blocks) but has  no missing block on its border (its outermost rows
	and columns)
	For example, 1 single block leads to a 3x3 surrounding block zone

 CATEGORY:
	Missing Blocks

 CALLING SEQUENCE:
	zone = 	read_zone (image, list_miss_blocks [,zone_width, zone_height])

 INPUTS:
	image				the image containing the zone to read
	list_miss_blocks		a list of missing blocks (or 1 block)
					that the missing zone will surround
 KEYWORD INPUT:
	rebindex : rebin index (see fuzzy_image.pro)

 OUTPUTS:
	zone				the zone surrounding these blocks

 Optional OUTPUTS:
	zone_width, zone_height 	the dimentions of the zone, in pixels

 MODIFICATION HISTORY:
	Written by J.MORE, September 1996
	Add of rebindex keyword on 28/01/2000 by A.Thernisien


REDUCE_DAILY

[List of Routines] (See ./reduce_daily.pro)

 NAME:
	REDUCE_DAILY

 PURPOSE:
	This procedure performs the reduction tasks that are done on a daily basis.

 CATEGORY:
	LASCO REDUCE

 CALLING SEQUENCE:
	REDUCE_DAILY

 INPUTS:
	None

 OPTIONAL INPUTS:
	STDate:	A string in the format YYMMDD that defines the starting date to be processed.
		If not present, the routine looks at the dates in daily.dat
	ENDATE:	A string in the format YYMMDD that defines the ending date to be processed.
		If not present, then only one date is processed
	
 KEYWORD PARAMETERS:
	LZ:	If present the level 0 data are to be processed.  The default is
		to process the quick look data.
	NOMED:	Do not do daily median images
	NO_C3:	Do not do C3 daily medians

 PROCEDURE:
	This procedure calls the routines to do the following tasks:

		check the monexp file for duplicates
		generate the daily median image
		generate PB and %P images

	All 4 telescopes are processed.

 EXAMPLE:
	To process the quick look files for June 1, 1998:

		REDUCE_DAILY,'980601'

	To process the level 0 files for June 1, 1998:

		REDUCE_DAILY,'980601',/lz

 MODIFICATION HISTORY:
 	Written by:	RA Howard, NRL, 6/19/98
	NB Rich	 6/23/98	Comment out make-movie calls
	NB Rich 11/06/98 	Add DO_POLARIZE
	NB Rich 07/07/99	Fixed typo with 'endate'
	NB Rich    12/99	Add NOMED keyword
	NB Rich	   01/00	Add NO_C3 keyword
       D  Wang 12 Jul 00       Added /VIG,/PTF to DO_POLARIZ call
	NB Rich 11 Jan 01	Fix call to open weekly.dat
	NB Rich 13 Apr 01 	Add NOREBIN to calls to MK_DAILY_MED
	NB Rich 31 Jan 02	Add /SH to spawn calls
	jake	030716		removing old commented out code
						fixing indentations


	@(#)reduce_daily.pro	1.8 07/16/03: LASCO IDL LIBRARY


REDUCE_IMAGE

[List of Routines] (See ./reduce_image.pro)

 NAME:				REDUCE_IMAGE

 PURPOSE:			Perform the pipeline processing for one file

 CATEGORY:			REDUCTION

 CALLING SEQUENCE:		REDUCE_IMAGE,File_name,Source

 INPUTS:			File_name = Name of DDIS file to be processed
				Source    = 0 for R/T processed at GSFC
					    1 for R/T processed at NRL
					    2 for Level 0/PB processed at NRL

 OUTPUTS:			None

 OPTIONAL OUTPUTS:		None

 COMMON BLOCKS:		DBMS

 SIDE EFFECTS:			Moves DDIS file, Creates FITS file

 PROCEDURE: 			Processes a new image created by DDIS and 
				detected by the CRON job moves the image to a 
				new directory for permanent storage.  Log 
				entries are written.

 MODIFICATION HISTORY:		Written, RA Howard, NRL, 13 Oct 1995
   Version 1
           2      RAH    15 Nov 1995    Modified log output
           3      RAH    14 Dec 1995    Corrected condition to call to reduce_level_1

       @(#)reduce_image.pro	1.1 04 Apr 1996 LASCO IDL LIBRARY


REDUCE_IMG_HDR

[List of Routines] (See ./reduce_img_hdr.pro)

 NAME:
	REDUCE_IMG_HDR

 PURPOSE:
	This procedure appends information from the current image header to 
	the header files in $LAST_IMG and in the current image directory.

 CATEGORY:
	REDUCTION

 CALLING SEQUENCE:
	REDUCE_IMG_HDR, Hdr

 INPUTS:
	Hdr = FITS header

 OPTIONAL INPUTS:
	None
	
 KEYWORD PARAMETERS:
	DAY_ONLY	Only update current directory

 OUTPUTS:
	None

 OPTIONAL OUTPUTS:
	None

 MODIFICATION HISTORY:
	Written, RA Howard, NRL
   VERSION 1  rah 16 Dec 1995
           2  rah 28 Dec 1995  Changed environment variable to LAST_IMG
           3  rah 29 Mar 1996  Write info to date directory also
           4  rah  4 Apr 1996  Modify filt/polar filed to be A6 from A5
           5  rah 26 Aug 1996  Added FP WL and OS Num to listing
	    6  nbr  6 Mar 1997  Write info to catalogs/daily directory
	    7  sep  3 Sep 1997  Write info to catalogs/daily_combined directory
           8  aee 21 Oct 1997  If level 1 or 2 image, write img_hdr.txt info 
                               only to the date directory.
	nbr 29 Aug 2000	- Write catalog files to $LAST_IMG instead of $IMAGES;
			  Add DAY_ONLY keyword
	nbr 11 Oct 2000 - Write img_hdr.txt file in $IMAGES also if NE $LAST_IMG
	nbr  9 Apr 2003 - Modify for level 1 processing
	nbr 25 Aug 2003 - imghdr changes
       k.battams 6/03/2005 -- get correct format for Level-1 img_hdr's

 SCCS variables for IDL use
 
 @(#)reduce_img_hdr.pro	1.13 09/08/03 :NRL LASCO IDL LIBRARY



REDUCE_LEVEL_05

[List of Routines] (See ./reduce_level_05.pro)

 NAME:
		REDUCE_LEVEL_05

 PURPOSE:
		Perform the Level 0.5 Processing

 CATEGORY:
		REDUCTION

 CALLING SEQUENCE:
		Result = REDUCE_LEVEL_05 (File_name,Fits_name,Source)

 INPUTS:
		File_name = Name of file to process in the 
				            format YYMMDD_HHMMSS.img
		Source    = parameter indicating file source

 OPTIONAL INPUTS:
		Fits_name = If DB_ONLY is set, then use this file to create 
				a database update file
	
 KEYWORD PARAMETERS:
	DB_ONLY		If set, then only create database update file from 
			input fits_name

 OUTPUTS:
 		Fits_name = Name of FITS file created
   		Result = 0 do process to level 1
			 1 don't process to level 1

 OPTIONAL OUTPUTS:
		None

 COMMON BLOCKS:
		DBMS

 PROCEDURE:

   processes a compressed LEB image created by DDIS to level 0.5
   the image is assumed to be located in the current directory
   level 0.5 consists of 
           decompression
           remove readout port effect
           rotate image to put solar north at top of image
           make FITS file
	    generate DBMS update records
           make gif file for lastimg_cx

   The level 0.5 image file is named according to the standard name 
   convention in the subdirectory tree:  
              $IMAGES/level_05/date/tel
   Note: if dark, cal lamp or continuous image then put in 
              $IMAGES/misc/tel/[dark,lamp,cont]/date
         if header from Ground to Peripheral LP then put in 
              $IMAGES/misc/leb/gnd/date

 MODIFICATION HISTORY:
 	WRITTEN    RA Howard, 3 October 1995
   Version 1      rah    3 Oct 95    Initial release
           2      rah    6 Nov 95    Add log output
           3      rah   15 Nov 95    Modified log output
           4      rah   11 Dec 95    Changed call to write_last_image to be 
                                     fits header
           5      rah   15 Dec 95    Changed call to rectify to be fits header
           6      rah   11 Jan 96    Changed rectify to include solar north
           7      rah   12 Jan 96    Added call to rectify P1, P2 coords
           8      rah   17 Jan 96    Corrected handling of read_leb_image 
                                     image read error
           9      rah   29 Mar 96    Rearranged reduce_img_hdr to be after 
				      changing to date directory to be able to
				      write img hdr also to date directory.
				      Changed browse image to be 128 x 128
				      Changed browse name to form from fits
                                     Added call to REDUCE_STATISTICS
                                     Added call to fill up DBMS IMG_STATS
          10      rah   03 Apr 96    Added DBMS update of leb_img_hdr & _ip
                                     Added non-hdr parameters to leb_img_hdr
          11      rah   10 Apr 96    Only compute stats if image found
          12      rah   15 Apr 96    Added call to REDUCE_REFCOORD
          13      sep   04 Jun 96    Added compression_str to img_leb_hdr table
                                     Corrected insertions into img_ip table
          14      sep   28 Jun 96    Added chmod 640 on .fts files
          15      sep   17 Jul 96    Modified for new LEB hdr (obev145+)
                                     added version and fp_order to DB updates.
          16      sep   02 Oct 96    added proc_time, p1row, p1col, p2row, p2col to DB updates.
          17      rah   21 Oct 96    added fits_hdr in call to make_browse
	   18	   nbr   11 Mar 97    print FITS_filename and directory 
	   19	   rah   23 Mar 97    moved REDUCE_REFCOORD and REDUCE_STATISTIC
                                     to always process, not just if DISPLAY
                                     Also, added call to CHECK_OBESUMERROR
          20      sep   13 Jun 97    Modified for new LEB hdr (obev203+)
          21      aee   27 Jun 97    Added unique_os field to img_leb_hdr
          22      rah   18 Jul 97    Check for image summing/differencing
          23      sep   14 Apr 98    Modified diskpath entry to use $IMAGES (always /net/corona/cplex..)
          24      rah   12 Jun 98    Add monexp and dark calcs
	   25      nbr   31 Jul 98    Change diskpath to use $DSKPATH
	   26	   nbr   22 Oct 98    Use LASCO_FITSHDR2STRUCT, not FITSHDR2STRUCT
	   27	   nbr   09 Mar 99    Set a.dateorig='NULL' for img_leb_hdr table
	   28	   nbr   12 Apr 99    Set chmod to 644 on .fts files
	nbr	29 Aug 00 - Change to SCCS version for ver; Use $LAST_IMG as location
			    of link directory if different from $IMAGES
          30      aee   21 Nov 00    Subtract lpulse from exp3 (and therefore from exptime)
                                     for cal lamp images on and after july 28, 1997.
	nbr	22 Jan 01 - Add door_cls output directory
	nbr 	30 Nov 01 - Add DB_ONLY option
	nbr	11 Dec 01 - Fix ss variable definition
	nbr	 1 Feb 02 - Add /SH to SPAWN calls
	jake	030721	added CROTA[12] keywords to EIT images
					(these keywords are added to LASCO in REDUCE_REFCOORD)
	jake	030804	replaced GET_SOHO_ROLL with GET_CROTA
                                     

 SCCS variables for IDL use
 
ersion=  '@(#)reduce_level_05.pro	1.29 08/04/03' ; LASCO IDL LIBRARY



REDUCE_LEVEL_1

[List of Routines] (See ./reduce_level_1.pro)

 NAME:
	REDUCE_LEVEL_1

 PURPOSE:
	This procedure performs the standard pipeline processing to 
	take the level 0.5 image to Level 1. 
   *** Note: This procedure is now designed to operate without
	any calling procedure. Simply input a level_05 FITS
	filename with path and it will do the rest.
	- NBR, 8/4/00

 CATEGORY:
	LASCO REDUCTION

 CALLING SEQUENCE:
	REDUCE_LEVEL_1, Fits_name

 INPUTS:
	Fits_name = Name of FITS file to process, including path

 OPTIONAL INPUTS:
	$RED_L1_PATH, $REDUCE_OPTS: environment variable for pipeline processing
	
 KEYWORD PARAMETERS:
  /REM_CR	Perform cosmic ray removal algorithm - THIS OPTION IS NOT RECOMMENDED because it 
		doesn't work very well
  /NO_VIG	Do not apply vignetting correction
  /PIPELINE	Process for pipeline (saves in pipeline directory, creates database entry)
  /RESET	Read in calibration images (vignetting, mask, ramp, etc.) from file instead
		of using what is stored in the common block
  SAVEDIR = 'pathname'		Directory to save output in. Default is current directory.


 OUTPUTS:
   Default:
	Writes FITS file in current directory or SAVEDIR (or $IMAGES if PIPELINE set)
	Writes ./reduce_level_1.log (or unique log file if PIPELINE set)
	Description of keywords in FITS header are at 
		http://lasco-www.nrl.navy.mil/level_1/level_1_keywords.html

 OPTIONAL OUTPUTS:
	None

 COMMON BLOCKS:
	DBMS, REDUCE_HISTORY

 RESTRICTIONS:
	Must have LASCO IDL Library
	Must have environment $LASCO_DATA defined
	The REM_CR option is not currently supported outside of NRL
  ***  Current versions of calibration files only tested for images observed before July 1998!!! ***
   	Polarization processing or background removal is Level 2

 PROCEDURE:

   Level 1 consists of calibrating for 
           dark current
           flat field
           stray light 
           distortion  
           vignetting  
           photometry (physical units)
	    corrected time and position


 MODIFICATION HISTORY:
		Written	 RA Howard, NRL
   Version 1	rah  3 Oct 1995    Initial release
           2   rah 15 Nov 1995    Modified log output
           3   rah 21 Oct 1996    Added fits_hdr to make_browse
           4   aee 23 Oct 1997    Added fits name error handling and camera 
                                  case statement and modified the code to
                                  use C3_CALIBRATE instead of photocal. Also
                                  introduced environment variable 
                                  REDUCE_L1_OPTS which must contain 'DBMS'
                                  in order to create a DB file. Set negative
                                  image intensity values to zeros. Also adds
                                  image info to the img_hdr.txt file. Also
                                  added stray light and distortion correction.
	   	nbr  5 Oct 1998	   changed output directory; no database entry
	    5   nbr  1 Mar 1999    Added header updates from GET_IMG_LEB_HDR_UPDATES;
				   added IMG_LEB_HDR for .db files; open .db file
	nbr  4 Aug 2000 - Update version recording; reconstruct FITS header for Level 1;
			  compute roll, suncenter, time corrections
	nbr  7 Aug 2000 - Edit HISTORY fields
	nbr 26 Oct 2000 - Edit call to C3_CALIBRATE
	nbr 14 Nov 2000 - Add header field N_MISSING, REM_CR keyword
	nbr 12 Jan 2001 - Apply mask after warp
	nbr 25 Jan 2001 - Add bkg, mask_blocks, zblocks0 to common block; add MISSLIST to header
	nbr 15 Feb 2001 - Add C2
	nbr 15 May 2001 - Change SOLAR_R to R_SUN in hdr
	nbr 31 May 2001 - Change $ANCIL_DATA to $LASCO_DATA
	nbr  8 Nov 2001 - Modify for use outside of pipeline; remove c3_cal_img COMMON block
	nbr  3 Dec 2001 - Make paths compatible with Windows SSW for GSV
	nbr 17 Dec 2001 - Make paths compatible with Windows SSW for GSV
	nbr 24 Jun 2002 - Use RED_L1_PATH for pipeline savedir and for log and db files;
			  use yyyymmdd for output dir
	nbr  5 Jul 2002 - Change comment for CROTA; reinsert READPORT in header because is 
			  used in offset_bias.pro
	nbr 17 Sep 2002 - Use BSCALE and BZERO to save images as integers; 
			  add BLANK keyword; use .txt instead of .sav for c3[2]nullblocks
	nbr  9 Jan 2003 - mask_flag=0 for debugging
	nbr 14 Mar 2003 - Reinsert COMMON c3_cal_img for mask; don't get mask in this program;
			  add fixwrap for summed images; convert only C3 Clear to type integer;
			  use adjust_hdr_tcr() for time, roll, suncenter
	nbr  9 Apr 2003 - reduce_img_hdr DAY_ONLY if not pipeline
	nbr 14 Apr 2003 - Modify to do monthly images.
	nbr 16 May 2003 - Modify keyword comments
	nbr 11 Sep 2003 - Change img_leb_hdr db update
	04.04.01, nbr - Use best available values post-interruption and note in header;
                obsolete TIME-OBS; rotate inverted images
       04.04.08, nbr - Update for bkg images
       05.07.25, nbr - Update/fix C3 mask implementation
       05/07/28 KarlB - Change output directory structure
       Aug 1,05  KB  - Another minor change to output dir

ersion= '@(#)reduce_level_1.pro	1.36, 08/01/05' ; LASCO IDL LIBRARY


REDUCE_MAIN

[List of Routines] (See ./reduce_main.pro)

 NAME:				REDUCE_MAIN

 PURPOSE:			Main program to search for new files created by
				DDIS to perform pipeline processing on.

 CATEGORY:			REDUCTION

 CALLING SEQUENCE:		REDUCE_MAIN, Src

 INPUTS:			None

 OPTIONAL INPUTS:		Src = 0 for processing R/T files at GSFC
 				      1 for processing R/T files at NRL
 				      2 for processing PB files at NRL
	
 KEYWORD PARAMETERS:		Auto = if set then use closed_img_file
                                      if not set then use closed_img_file2
                               reduce_only -- for use by user reduce only. Nobody  
                                       else should need it

 OUTPUTS:			None

 OPTIONAL OUTPUTS:		None

 COMMON BLOCKS:		DBMS

 SIDE EFFECTS:

 RESTRICTIONS:

 PROCEDURE:

 EXAMPLE:

 MODIFICATION HISTORY:		Written  RA Howard, NRL
    Version 1   RAH, 6 Nov 1995,    Initial Release
    Version 2   rah, 15 Nov 1995,   Added closed_img_file flag file
                                    Modified log printing
    Version 3   rah, 18 Nov 1995,   Added source as optional parameter
    Version 4   rah,  7 Dec 1995,   Minor corrections to version
    Version 5   rah,  4 Jan 1996,   Correction to handling of .mem files
    Version 6   rah, 15 Jan 1996,   Minor correction to file name and get_lun,luf
    Version 7   rah, 18 Jan 1996,   Corrected handling of contents of closed_img_file
				     to correct FP files
    Version 8   rah, 09 Apr 1996,   Added check of letter extension to filename
    Version 9   rah, 19 Apr 1996,   More mods to account for letter extension
    Version 10  rah, 27 Apr 1996,   Added error handling opening closed_img_file
    Version 11  rah, 08 May 1996,   Added creation of file for update list
    Version 12  nbr, 08 Apr 1997,   Changed target directories for .log and .db files
    Version 13  rah, 26 Aug 1997,   Error handling opening closed_img_file
    Version 14  rah, 27 Sep 1997,   Handling of files created out of time order
    Version 15  rah, 16 Jan 1998,   Process mem files first before img files
    Version 16  nbr, 03 Jun 1998,   Remove old .img dirs from previous session
    Version 17  rah, 19 Oct 1998,   Remove old log files for GSFC processing
    Version 18  nbr,  4 Jan 1999,   Add row to .db file to remove QL LEB_HDR
    Version 19  nbr, 20 Oct 1999,   Send message to user if gap between current and last
					.img files is > 1 hour; add check for good date
    Version 20  nbr,  4 Apr 2000,   Halt processing of QL for db update at 2AM; move save lastdate.sav
    Version 21  nbr, 24 Jul 2000,   Add /SH to spawn commands
    Version 22 nbr , 17 Oct 2001,   Change filename sent in email for db update halt
    Version 23 nbr,   1 Feb 2002 - Use /noshell keyword for two spawn commands; move chmod updates to end; Add /SH to SPAWN calls
    Version 23 nbr,   4 Feb 2002 - Move chmod to correct location
				jake,	030813	-	changed mail's to /usr/ucb/mail's
               Karl  14 Oct 2004 - Add reduce_only keyword to specify LASCO_DATA variable

			PLEASE CORRECTLY USE TABS FOR INDENTATION
			POORLY INDENTED CODE IS HARD TO READ

 @(#)reduce_main.pro	1.30 10/14/04 :LASCO IDL LIBRARY



REDUCE_RECTIFY

[List of Routines] (See ./reduce_rectify.pro)

 NAME:			REDUCE_RECTIFY
 PURPOSE:
	function procedure to rectify the CCD image to account
	for the port that the image has been read out
 
 CATEGORY:
 CALLING SEQUENCE:	x = REDUCE_RECTIFY (a,h)

 INPUTS:		a = input image
			h = FITS header

 OUTPUTS:		x = rectified image
			h will be modified to reflect the rectification

 OPTIONAL OUTPUT PARAMETERS:
 COMMON BLOCKS:
 SIDE EFFECTS:
 RESTRICTIONS:
 PROCEDURE:
	rectifies an image taken with the CCD camera to be as
	though the observer were looking through the CCD.
	The telescope is assumed to be an erecting one.

	If !order is 0, the image will be displayed on the screen
	properly.
 MODIFICATION HISTORY:

	rah 3/16/93  revised to use idl built in function, rotate
	rah 11/7/95  revised to accept readport as string or number
	V4  rah 11/7/95  revised to accept header as FITS header
	V5  rah 1/11/96  revised to rectify image for !order=0, origin at
                        bottom left of image
	V6  rah 1/14/96  EIT doesn't need a rotation, it is an inverting 
			 telescope
	V7  rah 1/30/96  Correction to C1
	V8  rah 3/6/96   Correction to C1 orientation and "R" coordinates

 SCCS variables for IDL use
 

	@(#)reduce_rectify.pro	1.1 04 Apr 1996 LASCO IDL LIBRARY


REDUCE_RECTIFY_P1P2

[List of Routines] (See ./reduce_rectify_p1p2.pro)

 NAME:	
			REDUCE_RECTIFY_P1P2

 PURPOSE:
			Generate R1 and R2 coordinates from the P1,P2
			CCD coordinates that simulate coordinates
			that would have been used if the CCD had been
			read out in the rectified position.
			
 CATEGORY:		
			LASCO REDUCTION

 CALLING SEQUENCE:
			REDUCE_RECTIFY_P1P2,Effport,Hdr

 INPUTS:		
			Effport:  A character 'A' to 'D' indicating
				  the CCD readout port, corrected for
				  the telescope position on the S/C
			Hdr:	  The FITS image header

 OUTPUTS:		
			None

 OPTIONAL OUTPUT PARAMETERS:
			None

 COMMON BLOCKS:
			None

 SIDE EFFECTS:
			Adds parameters R1COL, R1ROW, R2COL, R2ROW,
			EFFPORT to the FITS headers

 RESTRICTIONS:
			If the port is not A..D then the values of R1
			and R2 are just set to P1 and P2

			If R1 is less than 1, the R1 and R2 coordinates
			are adjusted accordingly

 PROCEDURE:
 MODIFICATION HISTORY:
	Version 1	RA Howard 11 Jan 96	Written

       @(#)reduce_rectify_p1p2.pro	1.1 04 Apr 1996 LASCO IDL LIBRARY


REDUCE_REFCOORD

[List of Routines] (See ./reduce_refcoord.pro)

 NAME:
	REDUCE_REFCOORD

 PURPOSE:
	Converts coordinate system to the standard coordinate system
	using the FITS keyword notation

 CATEGORY:
	LASCO DATA REDUCTION

 CALLING SEQUENCE:
	REDUCE_REFCOORD, Hdr, Level

 INPUTS:
	Hdr:	FITS header
	Level:	String indicating level to define coordinate system:
			'0.5', '1.0', '2.0'

 SIDE EFFECTS:
	Keywords are added to the FITS header, where n=1,2:
		CRPIXn, CRVALn, CROTAn, CDELTn, CTYPEn, CUNITn

 PROCEDURE:
	The 12 FITS keywords are computed for each of the processing
	levels and added to the header.  The keywords for one level
	do not require that the keywords for the preceeding level are 
	present.

 SUBROUTINE CALLS:
	FXPAR, FXADDPAR, GET_SUN_CENTER, GET_SEC_PIXEL

 MODIFICATION HISTORY:
       RA Howard, NRL, 14 April 1996
	Vers 1   14 Apr 1996, Initial Release
	     2   23 May 1997, All levels use solar coords
			030710 jake	added lines to account for nominal_roll_attitude
			030716 jake	using get_soho_roll instead of get_crota
			030804 jake replaced GET_SOHO_ROLL with GET_CROTA

	@(#)reduce_refcoord.pro	1.6 08/04/03 LASCO IDL LIBRARY


REDUCE_TRANSFER

[List of Routines] (See ./reduce_transfer.pro)

 NAME:				REDUCE_TRANSFER

 PURPOSE:			Peform the transfer of an image file
				created by DDIS into $LEB_IMG to the 
				appropriate subdirectory under $LAST_IMG

 CATEGORY:			REDUCTION

 CALLING SEQUENCE:	 	Result = REDUCE_TRANSFER (File_name, Source)

 INPUTS:			File_name = Name of DDIS file to transfer
				Source = parameter giving source of data

 OPTIONAL INPUTS:		None
	
 KEYWORD PARAMETERS:		None

 OUTPUTS: 			Result =  0 process to level 0.5
               			  1 don't process further

 OPTIONAL OUTPUTS:		None

 COMMON BLOCKS:

 SIDE EFFECTS:			None

 PROCEDURE:			
	The subdirectories under $RAW are:
	$RAW/YYMMDD if .img file
	The subdirectories under $IMAGES are not used in the procedure.
	The subdirectories under $LAST_IMG are:
       $LAST_IMG/misc/leb/mem/YYMMDD if memory dump
       $LAST_IMG/misc/leb/gnd/YYMMDD if ground to peripheral header
   Also enters the appropriate information into the data base

 MODIFICATION HISTORY:		Written, RA Howard, NRL

   Version 1	RAH   13 Oct 1995     Initial Release
           2   RAH   15 Nov 1995     Modified log printouts
           3   RAH   18 Mar 1996     Added leb summing to DB
           4   RAH   03 Apr 1996     Moved DBMS update of hdr & ip to 05
           5   RAH   09 Apr 1996     Check validity of image date
           6   RAH   29 Oct 1996     Added -f option to mv to force the move
	    7   NBR   19 May 1997     Use 'RAW' env var to place .img files
	    8	NBR   24 Dec 1997     Handle 0-length .img files
	    9   NBR   03 Feb 1999     Change upper bound of validdate to today + 2
		NBR   29 Aug 2000 - Use $LAST_IMG instead of $IMAGES
	NBR, 31 Jan 2002 - Add /SH to spawn calls


       @(#)reduce_transfer.pro	1.10 02/01/02 ; NRL LASCO IDL LIBRARY


REFORMAT

[List of Routines] (See ./reformat.pro)

 reformat.pro
 Run the reformatting code in the EOF
 
 SCCS variables for IDL use
 
 @(#)reformat.pro	1.1 05/14/97 :NRL Solar Physics


SOLAR_NORTH_UP

[List of Routines] (See ./solar_north_up.pro)

 NAME:				SOLAR_NORTH_UP

 PURPOSE:			Rotates the image to put the solar north at the
				top of the image.

 CATEGORY:			REDUCTION

 CALLING SEQUENCE:		Result = SOLAR_NORTH_UP (Img, Tel)

 INPUTS:			Img = Image array, corrected for readout port
				telescope = int representing telescope (0,1,2,3) -or-
					string representing telescope
 OPTIONAL INPUTS:		None
	
 KEYWORD PARAMETERS:		None

 OUTPUTS:			Result = Image array, corrected for telescope 
					 orientation

 OPTIONAL OUTPUTS:		None

 COMMON BLOCKS:

 SIDE EFFECTS:

 RESTRICTIONS:
   assumes that the images are already rectified so that the readout port 
   effect has been taken care of
   To visualize the images properly, the parameter, !order, should be set =1

 PROCEDURE:

 EXAMPLE:

 MODIFICATION HISTORY:		Written, RA Howard, NRL
   VERSION 1  rah 3 Nov 1995
   VERSION 2  rah 2 Jan 1996  EIT changed from 1 to 0
  	nbr, 3 Jan 2002 - Can use string camera as input

       @(#)solar_north_up.pro	1.2 01/03/02 LASCO IDL LIBRARY


SPLIT_QKL

[List of Routines] (See ./split_qkl.pro)

 NAME:		SPLIT_QKL

 PURPOSE:	Pre-process QKL files to split them up if they have gaps

 CATEGORY:	REDUCTION

 CALLING SEQUENCE:	SPLIT_QKL, yymmdd

 INPUTS:	date = Date to be processed

 OPTIONAL INPUTS:	None

 KEYWORD PARAMETERS:	None

 OUTPUTS:	None

 OPTIONAL OUTPUTS:	None

 COMMON BLOCKS:	UNPACK_SCIENCE

 PROCEDURE:
	A QKL file is broken into smaller files, for which the times in consecutive
	packets differ by no more than 30 secs.

 MODIFICATION HISTORY:
 	WRITTEN     4 Nov 1998 by Nathan Rich, Interferometrics/NRL
	12 Nov 1998	NBR	change qkl allowed gap to 30 sec
	30 Nov 1998	RAH	Check for undefined input date.
	020312		Jake	Added /SH to SPAWN

 SCCS variables for IDL use
 
 @(#)split_qkl.pro	1.7 03/12/02 :NRL Solar Physics



STRMAP2MB

[List of Routines] (See ./mb2str/strmap2mb.pro)

 PROJET:
	SOHO - LASCO

 NAME:
	STRMAP2MB

 PURPOSE:
  Convert a 'string map' to a missing block image map

 CATEGORY:
  missing blocks

 CALLING SEQUENCE:


 INPUTS:
  sm : string coded MB map
  sx,sy : size in pixel of the original image

 OPTIONAL INPUTS:
  rebindex : only necessary if 'full' parameter is passed
             rebin factor of the original image: 1 : full resolution
                                                 2 : half resolution
                                                 4 : quarter resolution
                                                 8 : 8th resolution
 OUTPUTS:
  mb : missing block map mask

 OPTIONAL OUTPUTS:

 KEYWORD INPUT:
  full : set to [frame_start_X,frame_start_Y] in 1024 CCD pix if
         image is not full field

 MODIFICATION HISTORY:
	V1.0 Writen by A.Thernisien on 18/07/2001
 CVSLOG:
  $Log: strmap2mb.pro,v $
  Revision 1.2  2002/07/11 07:24:19  arnaud
  Insertion of the Log in each header



UNPACK_ALL_SCIENCE

[List of Routines] (See ./unpack_all_science.pro)

 NAME:				UNPACK_ALL_SCIENCE

 PURPOSE:			Main program to unpack all science TM files
				from DACS, or ECS into raw DDIS files

 CATEGORY:			REDUCTION

 CALLING SEQUENCE:		UNPACK_ALL_SCIENCE, Date

 INPUTS:			None

 OPTIONAL INPUTS:		Date = Date to be processed, YYMMDD
				       If date is not present, then all
				       science files in $LEB_IMG will be 
				       processed.
	
 KEYWORD PARAMETERS:		/QKL	Set to process only QKL files

 OUTPUTS:			None

 OPTIONAL OUTPUTS:		None

 COMMON BLOCKS:		unpack_science

 SIDE EFFECTS:

 RESTRICTIONS:

 PROCEDURE:

 EXAMPLE:

 MODIFICATION HISTORY:		Written  RA Howard, NRL
    Version 1   RAH, 21 Dec 1995,    Initial Release
    Version 2   RAH, 23 Dec 1995,    Changed to read in QKL and REL files
    Version 3   RAH, 25 Dec 1995,    Added call to reduction processing
    Version 4   RAH, 28 Dec 1995,    Removed call to reduction processing
    Version 5   SEP, 14 Jan 1996,    Sort QKL/REL by time
    Version 6   RAH, 19 Jan 1996,    Modified FP file names
    Version 7   RAH, 26 Jan 1996,    Corrected write if nwds=0
    Version 8   RAH, 22 Apr 1996,    Mods for TM returning after 0 or FF
    Version 9   RAH, 01 Aug 1996,    Added check for end of packet
    Version 10  RAH, 27 Aug 1996,    Correct ddis_name for duplicate times
    Version 11  SEP, 12 Dec 1996,    Sort High & Low packets by time
    Version 12  NBR, 29 Dec 1997,    Ensure pkidwd is less than pktsize in 
					UNPACK_SCIENCE_PACKET
    Version 13  NBR, 13 May 1998,    Fix findfile to not find *.SDU files
    Version 14  NBR,  4 Nov 1998,    Call SPLIT_QKL.pro for QKL files
    Version 15  NBR, 16 Nov 1998,    Added QKL keyword
    Version 16  NBR, 11 Dec 1998,    Do not call SPLIT_QKL with QKL keyword
    Version 17  NBR,    Feb 2000,    Fix unpack_science_packet again
    Version 18  NBR,    May 2000,    Fix endelse in unpack_science_packet
    Version 19  NBR, 31 Jan 2002,    Add /SH to spawn calls


       02/01/02 @(#)unpack_all_science.pro	1.15 LASCO IDL LIBRARY


UNPACK_LZ_SCIENCE

[List of Routines] (See ./unpack_lz_science.pro)

 NAME:				UNPACK_LZ_SCIENCE

 PURPOSE:			Main program to unpack all science TM files
				from Level-0 disks into raw DDIS files

 CATEGORY:			REDUCTION

 CALLING SEQUENCE:		UNPACK_LZ_SCIENCE [, filenames]

 INPUTS:			None

 OPTIONAL INPUTS:		Name of d01 file[s] to be processed
	filenames	STR or STRARR	 Ex.: '70750101.d01'
	
 KEYWORD PARAMETERS:		None

 OUTPUTS:			None

 OPTIONAL OUTPUTS:		None

 COMMON BLOCKS:		unpack_science

 SIDE EFFECTS:

 RESTRICTIONS:

 PROCEDURE:

 EXAMPLE:

 MODIFICATION HISTORY:		Written  RA Howard, NRL
    Version 1   RAH, 21 Dec 1995,    Initial Release
    Version 2   RAH, 23 Dec 1995,    Changed to read in QKL and REL files
    Version 3   RAH, 25 Dec 1995,    Added call to reduction processing
    Version 4   RAH, 28 Dec 1995,    Removed call to reduction processing
    Version 5   SEP, 14 Jan 1996,    Sort QKL/REL by time
    Version 6   RAH, 19 Jan 1996,    Modified FP file names
    Version 7   RAH, 26 Jan 1996,    Corrected write if nwds=0
    Version 8   RAH, 28 Feb 1996,    Mods for level-0
    Version 9   RAH, 21 Apr 1996,    Corrected when TM comes back after off
    Version 10  RAH, 04 Aug 1996,    Don't process if date < May 1996
					because getting disks out of order
					Also check for end of packet
    Version 11  RAH, 29 Aug 1996,    Correct ddis_name for duplicate times
    Version 12  RAH, 03 Sep 1996,    Correct for time jumps
    Version 13  RAH, 04 Feb 1997,    Correct high/low rate packet lengths
    Version 14  NBR,  3 Aug 1998,    Allow optional input of search parameter
    Version 15  NBR, 28 Jan 1998,    Check for gaps in packet file
    Version 16  NBR, 13 Sep 1999,    Stop for gaps of 10 min. or more
    Version 17 NBR, Feb 2000,	'first GT 0' instead of 'keyword_set(first)'; 
	If apid NE '88ac' or '88af' then skip packet and go on to the next
    Version 18 NBR, Apr 2000,  Fix case where most of packet is 255 (skip the packet)
    Version 19 NBR, 31 Jan 2002 - Add /SH to spawn calls
    03.10.09, nbr - Allow input of d01 filename(s)
    03/12/18 - KB - Changed findfiles() to findfiles('*d01') in Line #610


	@(#)unpack_lz_science.pro	1.28 12/18/03 LASCO IDL LIBRARY


UNPACK_REDUCE_MAIN

[List of Routines] (See ./unpack_reduce_main.pro)

 NAME:				UNPACK_REDUCE_MAIN

 PURPOSE:			Main program to perform pipeline processing 
                               on a file created by unpack_science 

 CATEGORY:			REDUCTION

 CALLING SEQUENCE:		UNPACK_REDUCE_MAIN, Filename, Src

 INPUTS:			Filename = file name to process
                        	Src = 1 for processing QL files at NRL
 				      2 for processing Level-0 files at NRL

 OPTIONAL INPUTS:		None
	
 KEYWORD PARAMETERS:		None

 OUTPUTS:			None

 OPTIONAL OUTPUTS:		None

 COMMON BLOCKS:		DBMS

 SIDE EFFECTS:

 RESTRICTIONS:

 PROCEDURE:

 EXAMPLE:

 MODIFICATION HISTORY:		Written  RA Howard, NRL
    Version 1   RAH, 25 Dec 1995,    Modified from REDUCE_MAIN, V3
    Version 2	NBR, 31 Jan 2002 - Add /SH to spawn calls

       @(#)unpack_reduce_main.pro	1.2 02/01/02 LASCO IDL LIBRARY


UPDATE_HDR_ROLLXY

[List of Routines] (See ./update_hdr_rollxy.pro)

 NAME:
       UPDATE_HDR_ROLLXY 

 PURPOSE:
       This function updates a level-1 hdr with the solar roll angle, sun xpos
       and sun ypos obtained from stars and also their running median
       equivalents. It also writes the number of stars used to calculate
       the center and total number of stars that could have been used. 
       Center values from time files start with 0 but in FTS header
       starts with 1, therefore 1 is added to these when updating the
       header.

 CATEGORY:
       LASCO_ANALYSIS

 CALLING SEQUENCE:
       Result = UPDATE_HDR_ROLLXY (Hdr)

 INPUTS:
       Hdr:      A LASCO header structure

 OUTPUTS:
       1:        Update Success
       0:        Update Failure

 PROCEDURE:
	Update the hdr using the time files as defined in the
	c*_rollxy_yymmdd.dat format files.

 MODIFICATION HISTORY:
       Written by:     98/10/06  Ed Esfandiari 


WHERE2D

[List of Routines] (See ./fuzzy/where2d.pro)

 PROJET:
	SOHO - LASCO

 NAME:
	WHERE2D

 PURPOSE:
	Performs the same job as the "where" function but for a 2D array

 PROCEDURE:
	Performs the same job as the "where" function, for a 2-dimentional
	array, but returns explicits a list of 2-D (x and y) subscripts,
	instead of 1-D subscripts for "where"

	Afterward, a 2-D subscripts array can be subscripted using the
	resulting subscript array w2d from where2d, with a sequence such as :
	arr( w2d(0,*), w2d(1,*) )   (instead of arr(w) with the where function)

 CATEGORY:
	Detection

 CALLING SEQUENCE:
	index2d = where2d(array [, count] )

 INPUTS:
	array		An array (or more generally an array expression)
			where the function will determine the nonzero elements

 OUTPUTS:
	The result is the list of 2-D subscripts of the nonzero elements, i.e.:
	_ if there are nonzero elements : a 2 x n array
	  the first and second columns contains respectively the x and y
	  subscripts of the non-zero elements of the array 
	_ if there are NO nonzero elements, the result is the scalar -1

 Optional OUTPUTS:
	count		the number of nonzero elements found by where2d
			(=number of rows of the output list, or 0 if empty)

 MODIFICATION HISTORY:
	v1.0 written by J.More, September 1996


WRITE_BLOCK

[List of Routines] (See ./fuzzy/write_block.pro)

 PROJET:
	SOHO - LASCO

 NAME:
	WRITE_BLOCK

 PURPOSE:
	sets the block at column i and row j

 PROCEDURE:
	sets the block (array of pixels) at column i and row j to a given
	array of values, or to a given constant value

 CATEGORY:
	Missing Blocks

 CALLING SEQUENCE:
	write_block, image, i, j, block

 INPUTS:
	image		the image where to write the block
			(image is both an input and a output)
	i, j		the column i and the row j of the block to change
			(i and j ranges from 0 to 31)
	block		the block (dim : size x size) to overwrite; it can be :
			_ a integer array
			_ a scalar value, which leads to a constant array

 KEYWORD PARAMETERS:
	SIDE		the side of the square blocks (default is 32 pixels)

 OUTPUTS:
	The block (i,j) on image is overwritted
	(image is both an input and a output)

 MODIFICATION HISTORY:
	written by J.More, September 1996


WRITE_CLOSED

[List of Routines] (See ./write_closed.pro)

 NAME:
	WRITE_CLOSED

 PURPOSE:
	This procedure writes the name of the latest *.img file located in 
	$LEB_IMG into closed_img_file2.  This file is used by REDUCE_MAIN.

 CATEGORY:
	LASCO DATA REDUCTION

 CALLING SEQUENCE:
	WRITE_CLOSED

 OPTIONAL INPUTS:
	Nfiles:	If this parameter is present, the file name of the nfile-th
		file will be written.  Otherwise the default is to write the
		name of the latest .img file
		
 OUTPUTS:
	This procedure creates the file $LEB_IMG/closed_img_file2

 EXAMPLE:
	Write the file name of the latest file in $LEB_IMG:

		WRITE_CLOSED

	Write the file name of the 2nd file in $LEB_IMG:

		WRITE_CLOSED,2

 MODIFICATION HISTORY:
 	Written by:	RA Howard, NRL, 23 Dec 1995
	Version 2  RAH  10 Apr 1996  Added parameter to write nfile/th name

	@(#)write_closed.pro	1.2 21 Apr 1996 LASCO IDL LIBRARY


WRITE_LAST_IMG

[List of Routines] (See ./write_last_img.pro)

 NAME:				WRITE_LAST_IMG

 PURPOSE:			Create GIF image of the last real time image
				processed so that xv can then read and display
				it.

 CATEGORY:			REDUCTION

 CALLING SEQUENCE:		WRITE_LAST_IMG,Img,Hdr

 INPUTS:			Img = Input Image array
				Hdr = FITS header

 OPTIONAL INPUTS:		None

 KEYWORD PARAMETERS:		None

 OUTPUTS:			None

 OPTIONAL OUTPUTS:		None

 COMMON BLOCKS:		None

 SIDE EFFECTS:			None

 RESTRICTIONS:			This must be done with IDL haveing an X window
				display.

 PROCEDURE:			Scales the image to not larger than 512 x 512,
				and creates a GIF image with annotation along
				the side

 EXAMPLE:

 MODIFICATION HISTORY:		Written, RA Howard, NRL
    VERSION 1   rah    9 Nov 1995
    VERSION 2   rah   16 Nov 1995  Conversions added
    VERSION 3   rah   29 Nov 1995  Modified layout
    VERSION 4   rah   11 Dec 1995  Modified Detector conversion
    VERSION 5   rah   12 Jan 1996  Changed assumption to be !order = 0
				    Added R1 and R2 in place of P1, P2
    VERSION 6   rah   19 Apr 1996  Modified scaling of EIT image
                                   Corrected display of PIXSUM to include LEB
    VERSION 7   rah   23 May 1996  Corrected handling of images outside of chip
    VERSION 8   rah   22 Jul 1996  Corrected handling of cals > 1024 lines
    VERSION 9   rah    8 Oct 1996  Added subtraction of background model
    VERSION 10  sep   18 Jun 1997  Changed call for new OFFSET_BIAS()
    VERSION 11  nbr   28 Oct 1998  Use current year for background image
    VERSION 12  rah    3 Mar 1999  Added test for C2/3 Cont RO and Dark
    VERSION 13  nbr   23 Mar 1999  Change header to structure before calling REDUCE_STD_SIZE
    VERSION 14  nbr   29 Sep 1999  Change min/max for C2 and C3
    V 15	nbr	Feb 2000    Use ANY_YEAR, new min/max for C2
		nbr, 31 Jan 2001 - Do not use ANY_YEAR for C2
		nbr, 21 Oct 2001 - Move placement of Logo
		nbr, 31 Jan 2002 - no change


 @(#)write_last_img.pro	1.24 08/11/03 :LASCO IDL LIBRARY


WRITE_ZONE

[List of Routines] (See ./fuzzy/write_zone.pro)

 PROJET:
	SOHO - LASCO

 NAME:
	WRITE_ZONE

 PURPOSE:
	Writes a missing zone
 
 PROCEDURE:
	Writes a missing zone (array of pixel) surrounding a given list of
	missing blocks onto an image

	A missing zone is defined as the smallest rectangle of blocks that
	surrounds a cluster of missing blocks (likely to be neighbor missing
	blocks) but has  no missing block on its border (its outermost rows
	and columns)
	For example, 1 single block leads to a 3x3 surrounding block zone

 CATEGORY:
	Missing Blocks

 CALLING SEQUENCE:
	write_zone, image, list_miss_blocks, zone 

 INPUTS:
	image			the image where to write the zone onto
				(image is both an input and an output)
	list_miss_blocks	a list of missing blocks (or 1 block) defining
				the missing zone
	zone			an array of pixels to overwrite onto the image

 KEYWORD INPUT:
	rebindex : rebin index (see fuzzy_image.pro)

 OUTPUTS:
	zone is overwritten onto image
	(image is both an input and an output)

 MODIFICATION HISTORY:
	Written by J.MORE, October 1996
	Add of rebindex keyword on 28/01/2000 by A.Thernisien


[1]

[List of Routines] (See ./reduce_statistics.pro)

 NAME:

	REDUCE_STATISTICS

 PURPOSE:

	This procedure generates image statistics for the level 0.5 processing.

 CATEGORY:

	LASCO REDUCTION

 CALLING SEQUENCE:

	REDUCE_STATISTICS, Img, Hdr

 INPUTS:

	Img:	The 2D image to compute statistics on.

	Hdr:	A FITS header

 OUTPUTS:

	Hdr:	The FITS header will have additional keywords added.

 PROCEDURE:
	Generates the following statistical quantities:
	   minimum value not equal to 0 
	   maximum value not equal to saturated (16383)
	   number of zero pixels
	   percentage of saturated pixels
	   percentile values for 1%, 10%, 25%, 75%, 90%, 95%, 98% 99%
	   mean of image
	   standard deviation of image


 MODIFICATION HISTORY:
 	Written by:	RA Howard, NRL, 20 Mar 1996
	Version 2  RAH, 19 Apr 1996   Made low a long word
	V3  RAH, 18 Jul 1997   Added check for data type for maximum

       @(#)reduce_statistics.pro	1.4 07/23/97 LASCO IDL LIBRARY


[2]

[List of Routines] (See ./std_int_scale.pro)

 NAME:

	STD_INT_SCALE

 PURPOSE:

	Scale the intensities of the input image into DN/sec, accounting for
	the bias in case of summing.

 CATEGORY:

	LASCO REDUCTION

 CALLING SEQUENCE:

	Result = STD_INT_SCALE(Img,Hdr)

 INPUTS:

	Img = Input Image array.
	Hdr = FITS header

 KEYWORDS:
	None

 OUTPUTS:
	The function returns a floating point image.

 PROCEDURE:
	The input header is examined to extract the on-chip and off-chip
	summing parameters, and the exposure time.  The appropriate bias
	value is subtracted off the image and then the resultant is 
	divided by the exposure time.

 MODIFICATION HISTORY:
	Written, RA Howard, NRL, 22 October 1996

       @(#)std_int_scale.pro	1.1 10/22/96     LASCO IDL LIBRARY


[2]

[List of Routines] (See ./reduce_statistics2.pro)

 NAME:

	REDUCE_STATISTICS2

 PURPOSE:

	This procedure generates image statistics for the level 1 processing.

 CATEGORY:

	LASCO REDUCTION, modified

 CALLING SEQUENCE:

	REDUCE_STATISTICS2, Img, Hdr

 INPUTS:

	Img:	The 2D image to compute statistics on.

	Hdr:	A FITS header

 KEYWORDS:

	SATMAX	set equal to value to be considered saturated (upper cutoff)
	SATMIN	sat equal to value to be considered minimum cutoff

 OUTPUTS:

	Hdr:	The FITS header will have additional keywords added.

 PROCEDURE:
	Generates the following statistical quantities:
	   minimum value not equal to 0 
	   maximum value not equal to saturated (input value or max of image)
	   number of zero pixels
	   percentage of saturated pixels
	   percentile values for 1%, 10%, 25%, 75%, 90%, 95%, 98% 99%
	   mean of image
	   standard deviation of image


 MODIFICATION HISTORY:
 	Written by:	NB Rich, NRL -- Copied from REDUCE_STATISTICS.PRO by RA Howard
	NBR, 1 Sep 1998	 Make generic, change name, add sat input 
	NBR, 19 Jan 2001 - Change value of DATASAT keyword in output
	NBR, 29 Aug 2002 - Add SATMAX keyword in input and change handling of this value; 
			add SATMIN; add NDATASAT, DSATMIN, NDSATMIN in output
	NBR, 11 Mar 2003 - Do percentiles before truncation if SATMAX set

       03/14/03 @(#)reduce_statistics2.pro	1.3 LASCO IDL LIBRARY


This page was created by IDL lasco_mk_html_help.pro on Wed Aug 17 12:22:01 2005.