;+
; NAME:
;	ADD_MISSING_BLOCKS
;
; PURPOSE:
;	Masks blocks in the input image which are identified in the MISSLIST
;	keyword.
;
; CATEGORY:
;	LASCO Level 1 post-processing
;
; CALLING SEQUENCE:
;
;	Result = add_missing_blocks(image, header)
;
; INPUTS:
;	image	LASCO image with filled-in missing blocks (if any)
;	header	LASCO header structure
;
; KEYWORD PARAMETERS:
;
; OUTPUTS:
;	image with missing blocks masked
;
; COMMON BLOCKS:
;
; SIDE EFFECTS:
;
; RESTRICTIONS:
;
; PROCEDURE:
;	Obtain coordinates of missing blocks from MISSLIST keyword; create
;	a mask of the blocks; warp the mask; multiply image by the mask
;
; MODIFICATION HISTORY:
; 	Written by:	Nathan Rich,  8/29/02.
;
;	@(#)add_missing_blocks.pro	1.1 10/01/02 LASCO IDL LIBRARY
;-
function add_missing_blocks, im0, h

im = im0
IF datatype(h) NE 'STC' THEN h = lasco_fitshdr2struct(h)

missing = fix(str_sep(h.misslist,' '))
spxa = bytarr(h.naxis1/32,h.naxis2/32)
spxa[*]=1
spxa[missing]=0
mask = rebin(spxa,h.naxis1,h.naxis2,/sample)
IF h.detector EQ 'C3' THEN maskw = c3_warp(mask,h) ELSE $
IF h.detector EQ 'C2' THEN maskw = c2_warp(mask,h) ELSE BEGIN
	message,'Missing block mask not warped!',/cont
	maskw = mask
ENDELSE

return, float(maskw)*im

END

