;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; ~dph/libidl/tg_extract.pro ; hack to "extract" a spectrum - distance from zero-order within ; some distance perpendicular from dispersion line ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; PRO tg_extract, hml, maxdist, y, z, y0, z0, dd, dxd, list_selected ; hml = 'h' or 'm' or 'l' (or uppercase) = HEG or MEG or LEG; ; specifies which arm of the 'x' to use for distance from ; dispersion line calculation. ; maxdist = mm max distance from dispersion line (h or m) to allow. ; y,z = input coordinates in focal plane ;; y0,z0 - the Origin - hopefully the zero-order coord ;; any point on the line will do, but w/ arbitrary offset in result. ; dd = mm, output vector of photon distances from zero order parallel to ; dispersion. ; dxd = mm, output vector of photon distances from dispersion line in ; perpendicular direction. ; list_selected = optional output vector of indices within input ; vectors of selected photons ;; NOTE: To get a list of all photons distances when treated as either all MEG ;; or HEG, use a maxdist larger than a CCD, say 50mm. Otherwise, the ;; dd,dxd pairs no longer correspond to the input vectors or ;; associated vectors (such as nord). (added optional output of list_selected) IF n_params() EQ 0 THEN BEGIN print,'tg_extract, hml, maxdist, y, z, y0, z0, dd, dxd, [list_selected]' return ENDIF ;;;;;;;;; establish variables and commons ;;;;;;;;;;;;;;;; ; ;;; these need to be tied to MARX parameters ; ;X_TG = 8635.0d ; mm focal distance, from HETG plate X_TG = 8782.8d ; mm focal distance, from HETG plate, XRCF ;X_TG = 5366.55d ; mm focal distance, from TOGA plate ; establish HEG and MEG specifics TG_Period = 2000.95d ; Angstrom, period ;TG_alpha = -5.9974d*!dtor ; dispersion direction angle [radians] ;TG_alpha = -5.0d*!dtor ; dispersion direction angle [radians] ;TG_alpha = -5.1908347d*!dtor ; dispersion direction angle [radians] TG_alpha = -5.69d*!dtor ; dispersion direction angle [radians] P_inner = TG_Period ; set common variable alpha_inner = TG_alpha ; set common variable ;@MEG.dat TG_Period = 4000.77d ; Angstrom, period ;TG_alpha = 3.9489d*!dtor ; dispersion direction angle[radians] ;TG_alpha = 4.7411532d*!dtor TG_alpha = 4.2*!dtor P_outer = TG_Period ; set common variable alpha_outer = TG_alpha ; set common variable ; LEG.dat TG_Period = 9903.90 ;TG_alpha = -0.9073 TG_alpha = 0.0059298040*!dtor P_middle = TG_Period ; set common variable alpha_middle = TG_alpha ; set common variable ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; select photons within specified distance perp. from dispersion line: ; (we don't have to select by HRMA shell, since HEG or MEG dispersion ; does this) alpha_dispersion is the angle of the dispersion line ; relative to the -S array's long axis (the axaf y coordinate) ; IF strupcase(hml) EQ 'M' THEN BEGIN alpha_dispersion = alpha_outer ENDIF ELSE IF strupcase(hml) EQ 'H' THEN BEGIN alpha_dispersion = alpha_inner ENDIF ELSE IF strupcase(hml) EQ 'L' THEN BEGIN alpha_dispersion = alpha_middle ENDIF ; the dispersion line by definition goes through (0,0) - NOT. ; dxd=-(y-y0)*sin(alpha_dispersion)+(z-z0)*cos(alpha_dispersion) list_selected = where(abs(dxd) LT maxdist) ; again, since we have defined the origin at (0,0) as the position of ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; NOT! ; the zero-order (not true for flight in general when there is aspect ; motion or an offset in pointing, but let's not consider it now), ; then the distance of the point from the zero order parallel to the ; dispersion is: dd = sqrt((float(y)-y0)^2+(float(z)-z0)^2 - float(dxd)^2) ; dd = sqrt((float(y)-y0)^2+(float(z)-z0)^2 + float(dxd)^2) ; adjust sign: ;;; (may not want to do this for toga hacks. neg_ords = where((y-y0) LT 0) IF (size(neg_ords))(0) NE 0 THEN dd(neg_ords) = -dd(neg_ords) ; select photons only within the specified distance: dxd = dxd(list_selected) dd = dd(list_selected) END ; A (crude) diagram of the geometry: ; ; o P4 ; o(y,z)=P1 = photon position ; \ ; \ ; \ ; o P2= intersection of perp from ; P1 to dispersion line ; ; ; ; o P0=(0,0) = origin == zero-order position; o P3 ; dispersion direction is from P0 to P2 ; ; X = P0_P1 ; dxd = P1_P2 ; dd = P0_P2 ; P0_P3 = y-axis of detector array ; P3_P4 = z-direction ; X^2 = y^2 + z^2 ; X^2 + dxd^2 = dd^2