function gt_corner, item, x=x, y=y, lower_left=lower_left, original=original, from_sc=from_sc ; ;+ ;NAME: ; gt_corner ;PURPOSE: ; Return the coordinate of the center of the lower left output pixel in ; full resolution equivalent (FRE) units. Optionally return in binned ; pixels relative to sun center. ;CALLING SEQUENCE: ; xy = gt_corner(index) ; x = gt_corner(index, /x) ; xy = gt_corner(index, /from_sc) ;METHOD: ; The input is always an SXT index. (or corresponding FITS header) ;INPUT: ; item - The SXT index. It can be an array. ;OPTIONAL INPUT: ; x - If set, just return the x (column) corner ; y - If set, just return the y (lines) corner ; lower_left - If set, return the center of the full resolution pixel which ; is in the lower left corner of the output pixel. There is a ; 0 pixel shift for FR, -0.5 for HR, and -1.5 for QR ; original - If set, return the original corner commanded (from index.sxt) ; from_sc - If set, then return the pixel address in summed pixels ; relative to sun center. This means that for a full frame ; HR image with the sun in the center of the image, the value ; would be (-256,-256). Sun center is the origin. ;OUTPUT: ; returns - The corner saved in FR IDL equivalent coordinates. ; It is a vector if the input is a vector. The default is ; a 2xN array where N is the size of the roadmap or index ; array. If you use the /X or /Y options, it is 1xN. ;METHOD: ; The value saved in INDEX.SXT.CORNER_CMD is misleading. It is the raw ; telemetry value * 4. Since there is an unsummed pixel first out of the ; CCD, the coordinate system becomes complicated. This routine corrects ; the CORNER_CMD value and returns the value in full resolution equivalent ; units (FRE). ;HISTORY: ; Written 6-Jun-93 by M.Morrison ; 14-Jun-93 (MDM) - Make it scalar if one element ; 17-Jun-93 (MDM) - Added /ORIGINAL option ; 18-Nov-93 (MDM) - Added some comments ; 5-Jan-94 (MDM) - Added /FROM_SC ; 17-Aug-2008 (Aki Takeda) - Modified to accept FITS header as input ;- ; qcen = 1-keyword_set(lower_left) ;0 if want lower left, 1 if want center ; siz = size(item) typ = siz( siz(0)+1 ) if (typ eq 8) then begin res = gt_res(item, original=original) off = [0.0, 0.5, 1.5] ;---------------------------------------- Extract information from the history portion ; History portion corner is saved as the address of the CENTER of the summed pixel q_fits=tag_exist(item,'SIMPLE',/top) ; avoid using HISTORY for FITS (Aug-2008 AkT) if (his_exist(item) and (not keyword_set(original))) and (q_fits ne 1) then begin out = float(item.his.corner_sav) if (keyword_set(lower_left)) then begin for ires=0,2 do begin ss = where(res eq ires) if (ss(0) ne -1) then out(*,ss) = out(*,ss) - off(ires) end end ;---------------------------------------- Extract information from the original portion ; Original corner is saved as the address of the lower left FR sub-pixel end else begin out = float(gt_corner_cmd(item)) ;takes care of FFI error if (keyword_set(lower_left)) then off = [0, 0, 0] for ires=0,2 do begin ss = where(res eq ires) if (ss(0) ne -1) then begin out(0,ss) = 1023 - out(0,ss) + off(ires) ;reverse coordinate system out(1,ss) = out(1,ss) + off(ires) end end ; xshap = gt_shape(item,/x) xshap = (xshap-1) * 2^res out(0,*) = out(0,*) - xshap ;convert from lower right to lower left corner end end else begin message, 'Input needs to be an SXT index', /info return, 0 end ; if (keyword_set(from_sc)) then begin sc = gt_sxt_cen(item) ;read from .HIS.SUN_CENTER if it exists, otherwise call SXT_CEN out(0,*) = (out(0,*) - sc(0,*) ) / (2.^gt_res(item)) out(1,*) = (out(1,*) - sc(1,*) ) / (2.^gt_res(item)) end ; if (keyword_set(x)) then out = reform(out(0,*)) if (keyword_set(y)) then out = reform(out(1,*)) ; if (n_elements(out) eq 1) then out = out(0) ;make it scalar ; return, out end