function zstructify,ihdr,template,imdim=imdim,add_standard=pflag ; ; On error, return to our caller... on_error,1 sihdr= size(ihdr) type = sihdr(sihdr(0)+1) if (type eq 7) then begin if not isvalid(imdim) then imdim = 1 ;;;;;;;;;;;;;;; ;; We got a string array -- convert to a fits header structure if(imdim(0) ge 3) then begin if (imdim(3) ge 1) then message,'ZSTRUCTIFY - Must only use one image at a time when using STRING headers!',/traceback end if(keyword_set(pflag)) then begin i2hdr = ihdr if (sxpar(i2hdr,'DATE-OBS') eq 0) and $ (sxpar(i2hdr,'DATE_OBS') eq 0) and $ (sxpar(i2hdr,'T_REF') ne 0) then begin t = zstr2utc(sxpar(i2hdr,'T_REF')) sxaddpar,i2hdr,'DATE_OBS',utc2str(t,/ecs,/truncate,/date_only) sxaddpar,i2hdr,'TIME_OBS',utc2str(t,/ecs,/truncate,/time_only) end if(sxpar(i2hdr,'CROTA') eq 0) $ then begin sxaddpar,i2hdr,'CROTA',sxpar(i2hdr,'CROT') sxdelpar,i2hdr,'CROT' end return, fitshead2struct(i2hdr,template, $ /add_standard) end else $ return, fitshead2struct(ihdr,template) end else $ if (type eq 8) then begin ;;;;;;;;;;;;;;; ;; We got a structure -- just apply the appropriate checks to it. if isvalid(imdim) then if (imdim(0) ge 3) then if(imdim(3) ne (size(ihdr))(1)) then $ message,'ZSTRUCTIFY - Dimensions of header must match dimensions of image!' if(keyword_set(pflag)) then begin if(zcheck_hdr(ihdr,/fix)) then return,ihdr else $ message,'ZSTRUCTIFY - hdr failed pointing check!' end else $ return, ihdr end message,'ZSTRUCTIFY - Need a string header array or a header structure!' end