function TMO_tracksky, box, center=center, p_axis=p_axis, frame=frame, $ pfov=pfov, plotx=plotx, south=south, north=north ;+ ; NAME: ; TMO_tracksky ; PURPOSE: ; ; CATEGORY: ; SMEI prototype camera: TMO ; CALLING SEQUENCE: ; INPUTS: ; box array[2,2]; type: integer; default: defined in href=smei_camera= ; defines two corners of box in the form [ [x1,y1], [x2,y2] ] ; relative to the lowerleft corner of a full image ; The box contains nx by ny pixels (nx=x2-x1+1, ny=y2-y1+1) ; OPTIONAL INPUT PARAMETERS: ; center=center array[2]; type: float; default: defined in href=smei_camera= ; 'center' must be defined relative to the same origin as 'box' ; p_axis=p_axis array[2]; type: float; default: defined in href=smei_camera= ; frame=frame array[m]; type: integer; default: 1 ; /plotx ; OUTPUTS: ; rfov array[2,nx,ny,m]; type: float ; rectangular coordinates of all pixels in box corrected for skymotion ; relative to the same origin as 'box' and 'center' ; OPTIONAL OUTPUT PARAMETERS: ; pfov array[2,nx,ny,m]; type: float ; polar coordinates of all pixels in box corrected for skymotion ; INCLUDE: @compile_opt.pro ; On error, return to caller ; CALLS: ; smei_camera, gridgen, Inside_Wedge, BadValue, TMO_skymotion, SuperArray, view ; PROCEDURE: ; For each of the pixels in 'box' the position in each frame is calculated after ; correcting it for skymotion. ; MODIFICATION HISTORY: ; JULY-2001, Paul Hick (UCSD/CASS; pphick@ucsd.edu) ;- plotx = keyword_set(plotx) if n_elements(frame) eq 0 then frame = 1 nframe = n_elements(frame) ; Fill in several camera parameters with defaults if not specified as keywords. fov = smei_camera(/get_structure) if n_elements(box ) eq 0 then box = [0,0,fov.nsize-1] ; Box enclosing whole fov if n_elements(center) eq 0 then center = fov.center ; Location of fov center (x,y coordinates) if n_elements(p_axis) eq 0 then p_axis = fov.axis ; Location of optical axis (phi, rad) limits = smei_camera(/get_fov_limits, optical_axis=p_axis) ; Corners of field of view [two phi,rad pairs] nx = box[2]-box[0]+1 ny = box[3]-box[1]+1 origin = -box[0:1]+center ; Shifts origin from box[0:1] to center ;r = indgen2D([nx,ny], orig=-box[0:1]+center, /twod) r = gridgen([nx,ny], origin=origin, /multid) ; Rect. coord relative to center r = reform(r, 2, n_elements(r)/2, /overwrite) r = cv_coord(from_rect=r, /to_polar) ; Polar CCD coordinates in = Inside_Wedge(limits, r) ; Find pixels inside fov out = where(1-in) in = where(in, nfov) Bad = BadValue(r) if nfov gt 0 then begin if out[0] ne -1 then r[*,out] = Bad ; Flag locations outside fov as 'bad' ; Array[2, nx*ny, nframe]; polar coordinates pfov = TMO_skymotion(r, p_axis, frame, south=south, north=north) ; (corrected for skymotion during transit) rfov = bytarr(nx*ny, nframe) rfov[in,*] = Inside_Wedge(limits, pfov[*,in,*]) ; Array[nx*ny, nframe]; find pixels inside fov out = where(1-rfov) in = where(rfov, n_in) pfov = reform(pfov, 2, nx*ny*nframe, /overwrite) if out[0] ne -1 then pfov[*,out] = Bad ; Pixels outside fov are flagged as 'bad' rfov = pfov ; Get rectangular coordinates if in [0] ne -1 then $ ; Shift origin back to box[0:1] rfov[*,in ] = cv_coord(from_polar=rfov[*,in], /to_rect)+SuperArray(center, n_in, /trail) pfov = reform(pfov, 2, nx, ny, nframe, /overwrite) rfov = reform(rfov, 2, nx, ny, nframe, /overwrite) if plotx then begin img = bytarr(nx, ny, /nozero) for ii=0,nframe-1 do begin img[*] = 0B x = rfov[0,*,*,ii] y = rfov[1,*,*,ii] n = where( finite(x) and box[0] le x and x le box[2] and box[1] le y and y le box[3] ) if n[0] ne -1 then begin x = round(x[n]) y = round(y[n]) img[x-box[0],y-box[1]] = !d.n_colors-1 view, in=img endif endfor endif endif else begin pfov = Bad rfov = Bad endelse return, rfov & end