pro align_prep, index, xx, yy, sc, code, $ ;------------------------- Alignment parameters ref_image=ref_image0, $ helio=helio0, date_helio=date_helio, $ suncoord=suncoord0, $ ffi_shift=ffi_shift, $ ccdcoord=ccdcoord0, $ qroll=qroll, $ roll=roll, $ qdebug=qdebug, qstop=qstop ;+ ;NAME: ; align_prep ;PURPOSE: ; This routine takes an index and figures out the location on the CCD ; for the extraction. It is used by SXT_PREP ;INPUT: ; index - The roadmap or index (not just times since the filter ; information is needed) ;OPTIONAL KEYWORD INPUT: ; See SXT_PREP for the definitions ; qroll - If set, then the roll correction will be applied and adjust ; the field of view location appropriately. ;OUTPUT: ; xx - The X CCD IDL coordinate for each image for the position ; specified in "suncoord" or "helio" ; yy - The Y CCD IDL coordinate for each image for the position ; specified in "suncoord" or "helio" ; sc - The sun center (x,y) coordinate for each image ;OPTIONAL KEYWORD OUTPUT: ; roll - The S/C roll in degrees ;HISTORY: ; Written 16-Aug-93 by M.Morrison ; 18-Aug-93 (MDM) - Replaced call to GET_SUNCENTER with SXT_CEN ; 9-Oct-93 (MDM) - Fixed typo ; 4-Jan-94 (MDM) - Incorporated the shift correction of the optical images to ; be aligned with the x-ray images ; - Added ROLL keyword output ; 8-Feb-94 (MDM) - Added QROLL keyword input to correct for the location selection ; 25-Feb-94 (MDM) - Corrected the logic so that it works properly for CCDCOORD ; option (it was accessing roll when it didn't need it, and ; it wasn't defined) ; 14-Nov-94 (MDM) - Modified to return an array of elements for CCDCOORD ; instead of two scalars ; 25-Apr-99 (GLS) - Corrected transformation of suncoords and helio coords ; by including call to conv_a2p. ; 28-Apr-99 (GLS) - Removed references to roll_use because this was a case of ; MDM-bogosity (roll should ALWAYS be used in the determination ; of pixel coordinates of the extracted fov regardless of whether ; the images are to be 'de-rolled' after extraction (qroll=1) ; or not (qroll=0). ; 12-Nov-05 (LWA) Added keyword ffi_shift to handle case of conv_a2p for FFI. ; 7-Nov-08 (LWA) Origin of this code is align_prep.pro.20080905. ; 12-Nov-08 (LWA) Use roll=0 for all true ffi's. ; 20-Nov-08 (LWA) Replaced suncoord0 and ccdcoord0 ;- ; pf=min(gt_pfi_ffi(index,/true_ffi)) ffi=keyword_set(ffi_shift) if (n_elements(ref_image0) ne 0) then begin siz = size(ref_image0) typ = siz( siz(0)+1 ) if (typ ne 8) then ref_image = index(ref_image0) else ref_image = ref_image0 end ;---------------------------------------- Figure out the pointing coordinates to register to ; code = 2 ;default is to register relative to sun center if (keyword_set(helio0)) then code = 1 ;using heliocentric coorinates if (keyword_set(suncoord0)) or ffi then code = 2 ;using coordinates relative to sun center if (keyword_set(ccdcoord0)) then code = 3 ;using fixed IDL coordinates ; if (code eq 1) or (code eq 2) then begin sc = sxt_cen(index, roll=roll) ;need the sun center locations (in FR pixels) end case code of 1: begin ;heliocentric if ((n_elements(helio0) lt 2) or (n_elements(date_helio) eq 0)) then begin ;did not come in defined if (n_elements(ref_image) eq 0) then begin helio = gt_center(index(0), /helio) ;use the coordinates of the first image date_helio = anytim2ints(index(0)) end else begin helio = gt_center(ref_image, /helio) date_helio = anytim2ints(ref_image) end end else begin helio = helio0 end end 2: begin ;coordinates relative to sun center if not ffi or not pf and (n_elements(suncoord0) lt 2) then begin ;did not come in defined if (n_elements(ref_image) eq 0) then begin sunc = gt_center(index, /angle) suncoord = fltarr(2) suncoord(0) = total(sunc(0,*)) / n_elements(index) ;take the sun center position for all PFI images suncoord(1) = total(sunc(1,*)) / n_elements(index) ;and average them to get the center position end else begin if not pf then suncoord = gt_center(ref_image, /angle) else $ suncoord = gt_center(ref_image, /angle,roll=0.0) ; /angle - FOV center to sun center in arcsec ; (0,*) = angle in E/W direction with W positive ; (1,*) = angle in N/S direction with N positive end end else begin if not ffi then suncoord = suncoord0 end end 3: begin if (n_elements(ccdcoord0) lt 2) then begin ;did not come in defined if (n_elements(ref_image) eq 0) then begin ccd = gt_center(index) ccdcoord = intarr(2) ccdcoord(0) = total(ccd(0,*)) / n_elements(index) ;take the sun center position for all PFI images ccdcoord(1) = total(ccd(1,*)) / n_elements(index) ;and average them to get the center position end else begin ccdcoord = gt_center(ref_image) end end else begin ccdcoord = ccdcoord0 end end endcase ; ;---------------------------------------- Figure out the offsets ; fs = gt_sxt_axis(index, /rel_xray) ;filter shift in full resolution pixels relative to the x-ray axis (2xN) ;NB = (-0.36, 1.47) and NB image is NE of X-ray image ;so we need to start farther left, and higher on the CCD to compensate ==> + fs arcsec_per_pix = gt_pix_size() case code of 1: begin suncoord = reform(track_h2a(index, helio, date_helio)) ;need heliocentric motion (in arcsec) xy = conv_a2p(suncoord, index) ; Added call to conv_a2p for correct xx = xy(0,*) ; coordinate conversion (GLS - 25-Apr-99) yy = xy(1,*) end 2: begin case 1 of ffi : begin ;Don't use roll for FFIs. LWA 12-Nov-2005. ffi_shift = reform(rebin(ffi_shift,2,n_elements(index),/sample)) xy = conv_a2p(ffi_shift,index,roll=0.0) ; Added call to conv_a2p for correct end pf and not ffi : begin suncoord = reform(rebin(suncoord,2,n_elements(index),/sample)) xy = conv_a2p(suncoord,index,roll=0.0) end else : begin suncoord = reform(rebin(suncoord,2,n_elements(index),/sample)) xy = conv_a2p(suncoord,index) end endcase xx = xy(0,*) yy = xy(1,*) end 3: begin xx = ccdcoord(0) + fltarr(n_elements(index)) yy = ccdcoord(1) + fltarr(n_elements(index)) end endcase end