; ; $Id: dpm_crop.pro,v 1.4 1999/06/17 16:54:30 tdarnell Exp tdarnell $ ; ; CALLING SEQUENCE: dpm_crop[,filelist=files,xdim=x,ydim=y] ; ; PARAMETERS: All parameters are optional. If none are provided, dpm_crop ; will default to cropping all .fts images in current directory ; filelist is optional filelist ; xdim and ydim are user provided sizes for cropped images. If ; they are not supplied, dpm_crop defaults to 850x850 ; ; NOTES: This procedure will crop a series of HAO DPMON images to a ; smaller size more suitable for image processing. No ; resizing (i.e. CONGRID) is done, only an extraction of a ; smaller array from a much larger one. This procedure will ; probably crash if the sun is really close to an edge of the ; array. ; ; HISTORY: Drafted by Tony Darnell, 8-AUG-97 ; 12-MAY-99: Added pangle correction. ; ; PRO dpm_crop,filelist=filelist,xdim=xdim,ydim=ydim,no_worry=no_worry, $ no_pangle=no_pangle path=curdir() pangle=1.0 IF (NOT KEYWORD_SET(xdim)) THEN xdim=850 IF (NOT KEYWORD_SET(ydim)) THEN ydim=850 IF (KEYWORD_SET(filelist)) THEN filelist=rd_tfile(filelist) $ ELSE BEGIN filelist=file_list(path,'*asr.fts',/CD) filelist=strip_dirname(filelist) ENDELSE sz=SIZE(filelist) FOR i=0,sz(1)-1 DO BEGIN ;{ message,'Reading file: '+filelist(i),/INFORMATIONAL curr_image=readfits(filelist(i),curr_hdu,/silent) head=readfits(filelist(i),exten,/exten,/silent) curr_image[*,0]=curr_image[*,1] ;get rid of binary header. xsz=fxpar(curr_hdu,'NAXIS1') ysz=fxpar(curr_hdu,'NAXIS2') x_center=fxpar(curr_hdu,'CRPIX1') y_center=fxpar(curr_hdu,'CRPIX2') IF ((x_center LT 0) OR (y_center LT 0)) THEN BEGIN IF (KEYWORD_SET(no_worry)) THEN BEGIN MESSAGE,'Invalid centering info in header, using center of array.', $ /INFORMATIONAL x_center=xsz/2. y_center=ysz/2. ENDIF ENDIF pangle=fxpar(curr_hdu,'SOLAR_P0') IF (KEYWORD_SET(no_pangle)) THEN pangle=0.0 print,'x_center: ',x_center print,'y_center: ',y_center print,'pangle: ',pangle CATCH,file_err IF (file_err NE 0) THEN BEGIN ;{ MESSAGE,!ERR_STRING+' ,skipping this file',/INFORMATIONAL GOTO,leave_loop ENDIF ;} curr_image=it_center(curr_image,x_center,y_center) curr_sz=SIZE(curr_image) x_center=curr_sz(1)/2 y_center=x_center ; Correct the image for pangle. IF (pangle LT 0.) THEN pangle = pangle + 360. tmp_img=ROT(curr_image,pangle,1.0,x_center,y_center,/INTERP,/PIVOT) curr_image=tmp_img start_x = x_center-(xdim/2) start_y = y_center-(ydim/2) end_x = x_center+(xdim/2) end_y = y_center+(ydim/2) final_img =curr_image(start_x:end_x, start_y:end_y) final_sz = SIZE(final_img) final_xsz = final_sz(1) final_ysz = final_sz(2) fxaddpar,curr_hdu,'NAXIS1',final_xsz fxaddpar,curr_hdu,'NAXIS2',final_ysz fxaddpar,curr_hdu,'CRPIX1',final_xsz/2 fxaddpar,curr_hdu,'CRPIX2',final_ysz/2 fxaddpar,curr_hdu,'DISPMIN',20 fxaddpar,curr_hdu,'DISPMAX',550 fxaddpar,curr_hdu,'CROTA1',0.0,' IMAGE IS CORRECTED FOR P-ANGLE (DPM_CROP)' fxaddpar,curr_hdu,'CROTA2',0.0,' IMAGE IS CORRECTED FOR P-ANGLE (DPM_CROP)' filename=STRMID(filelist(i),0,STRLEN(filelist(i))-3) filename=filename+'crop.fts' MESSAGE,'Writing file: '+filename,/INFORMATIONAL MESSAGE,'as '+STRCOMPRESS(STRING(final_xsz))+' by '+ $ STRCOMPRESS(STRING(final_ysz))+' image.', $ /INFORMATIONAL writefits,filename,final_img,curr_hdu writefits,filename,head,exten,/append leave_loop: ENDFOR ;} ; ; Reset arrays so they take up less memory ; temp=0.0 final_img=0.0 curr_img=0.0 END