;+ ; NAME: ; FOVPIX ; PURPOSE: ; To determine the pixels in a Polar Camera image that ; approximate the (circular) field of view of a narrow-field ; photometer. ; CATEGORY: ; ; CALLING SEQUENCE: ; result = FOVPIX( YEAR, MONTH, DAY, CAM, ZA, AZ, HALFANG $ ; [, DEGREES=DEGREES] [, BIN = bin] [, DEBUG = debug]) ; INPUTS: ; YEAR, ; MONTH, ; DAY: Date (in Universal Time) of the image. ; CAM: Camera number (0/1). ; ZA: Zenith angle of the center of the field of view. ; AZ: Azimuth angle of the center of the field of view. ; HALFANG: Angle between the center and an edge of the field ; of view. ; OPTIONAL INPUTS: ; None. ; KEYWORD PARAMETERS: ; /DEGREES: Set if the angle inputs are expressed in degrees. ; The default is radians. ; BIN: The binning factor applied to the original 512x512 CCD ; array. Default = 2. ; /DEBUG: If set, execution STOPs just before RETURNing. ; OUTPUTS: ; The function returns a vector of indices into a standard ; 256x256 Polar Camera image, giving the pixels whose view ; directions lie within HALFANG of the direction (ZA,AZ). ; OPTIONAL OUTPUTS: ; None. ; COMMON BLOCKS: ; None. ; SIDE EFFECTS: ; A file of image transformation parameters is read to set ; up the (COL,ROW) -> (AZ,ZA) conversion. ; RESTRICTIONS: ; No warning is issued if the requested field of view lies ; outside the imaged portion of the sky. ; PROCEDURE: ; The transformation parameters for the specified date and ; camera are read. Arrays of azimuth and zenith angle are ; generated for the pixels of the specified camera image, ; and angular distances from the input direction are calculated. ; The indices of pixels lying within the specified half-angle ; are returned. ; EXAMPLE: ; east30=FOVPIX(1993,12,8,0,30,90,1.0,/DEGREES) ; returns ; ; the pixel indices for a 1-deg half-angle field of view ; ; at zenith angle 30 deg toward the East (azimuth 90 deg). ; SEE ALSO: ; CR2AZ.PRO ; MODIFICATION HISTORY: ; Written by: D P Steele, ISR, 18 Oct 1994 ;- FUNCTION fovpix,year,month,day,cam,za,az,halfang $ ,degrees=degrees,bin=bin,debug=debug IF N_PARAMS() LT 7 THEN BEGIN doc_library,'fovpix' RETURN,-1 ENDIF yr=year IF KEYWORD_SET(degrees) THEN f=!DTOR ELSE f=1. IF N_ELEMENTS(bin) EQ 0 THEN bin=2 zenang=f*za ; convert input angles azim=f*az ; to radians hlfang=f*halfang ; for computations col=REBIN(INDGEN(256),256,256) ; generate column and row=TRANSPOSE(col) ; row number arrays cr2az,yr,month,day,cam,0,col,row,camaz,camzen $ ; convert to azimuth and ,degrees=degrees,bin=bin,site=PCsite ; zenith angle arrays angdist=ACOS(COS(zenang)*COS(camzen*f)+ $ ; from desired (AZ,ZA) COS(azim-camaz*f)*SIN(zenang)*SIN(camzen*f)) IF KEYWORD_SET(debug) THEN STOP RETURN,WHERE(angdist LT hlfang) ; returned indices in FOV END