pro readimg,fname,im,hdr,radius,a,d,ep,pixel=pixel,x0=x0,y0=y0 if n_params(0) eq 0 then begin print,'readimg,fname,im,hdr [,radius,a,d,ep,pixel=pixel,x0=x0,y0=y0]' print,'Loads fits image and truncates it to size radius (in arcmins)' print,'a,d is the center ra,dec of the resultant image (def. = center of input img)' print,'if ep is given, precess to image epoch to ep, if nec.' print,'Set /pix for (a,d) to be consider as pixel coordinates insteadof ra,dec' return endif im = readfits(fname,hdr) if n_params(0) gt 2 then begin rad = radius/60. nax1 = sxpar(hdr,'naxis1') nax2 = sxpar(hdr,'naxis2') extast,hdr,astr if n_params(0) lt 5 then begin x = nax1/2 y = nax2/2 xy2ad,x,y,astr,a,d print,'Center of image is at: '+adstring(a,d) endif else begin if keyword_set(pixel) then begin xy2ad,a,d,astr,ta,td a = ta d = td endif if n_elements(ep) gt 0 then begin equ = sxpar(hdr,'equinox') if equ eq 0 then equ = sxpar(hdr,'epoch') if equ ne ep then begin print,'Precessing (',strn(cx),',',strn(cy),') from ',strn(ep),$ ' to ',strn(equ) precess,a,d,ep,equ endif endif endelse flipx = 0 & flipy = 0 ad2xy, a+rad/cos(d/!radeg), d-rad, astr, x0, y0 ad2xy, a-rad/cos(d/!radeg), d+rad, astr, x1, y1 ; print,'x0,x1,y0,y1 = ',x0,x1,y0,y1 if (x0 gt x1) then begin swap = x0 & x0 = x1 & x1 = swap flipx = 1 endif if (y0 gt y1) then begin swap = y0 & y0 = y1 & y1 = swap flipy = 1 endif hextract,im,hdr,nim,nhdr,x0,x1,y0,y1 print,'Image bounds: (',strn(x0),',',strn(y0),') - (',strn(x1),$ ',',strn(y1),')' im = nim hdr = nhdr endif print,'Max. image value: ',strn(max(im)) return end