Viewing contents of file '../idllib/astron/contrib/varosi/vlibm/allpro/deconv_save.pro'
pro deconv_save, image_deconv, deconv_info, IMAGE=image, PSF=psf, $
					VERBOSE=verb, SAVE_IMAGES=save_images

; Save current deconvolution results to file.
; Frank Varosi NASA/GSFC 1992.

	if N_struct( deconv_info ) LE 0 then begin
		message,"missing 2nd arg:  deconv_info (structure)",/INFO
		return
	   endif

	fname = "DC-" + deconv_info.algorithm
	if strlen( deconv_info.data_name ) GT 0 then $
			fname = deconv_info.data_name + "-" + fname

	fname = dir_path( deconv_info.directory ) + fname
	deconv_info.systime1 = systime(1)
	deconv_info.size_deconv = size( image_deconv )
	if N_elements( verb ) NE 1 then verb=0

	if (deconv_info.Niter LE 0) then begin

		deconv_info.size_image = size( image )
		deconv_info.size_psf = size( psf )
		deconv_info.systime0 = systime(0)
		file = fname + ".0000"
		deconv_info.file = file

		if keyword_set( save_images ) then begin
			save, deconv_info, image, psf, image_deconv, $
							FILE=file, VER=verb
			print," saving results to files: ",fname,".(# iters)"
		  endif else begin
			save, deconv_info, FILE=file, VER=verb
			print," saving statistics to files: ",fname,".(# iters)"
		   endelse

	  endif else begin

		file = fname + "." + $
		   strmid( string( deconv_info.Niter+10000, FORM="(i5)" ),1,4 )
		deconv_info.file = file

		if keyword_set( save_images ) then $
			save, deconv_info, image_deconv, VERB=verb, FILE=file $
		  else	save, deconv_info, VERB=verb, FILE=file
	   endelse
return
end